You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
classMemoryFileSystem(AbstractFileSystem):
"""A filesystem based on a dict of BytesIO objects This is a global filesystem so instances of this class all point to the same in memory filesystem. """store: ClassVar[dict[str, Any]] = {} # global, do not overwrite!pseudo_dirs= [""] # global, do not overwrite!
... ok, but i need multiple different memory filesystems in parallel
This is a reasonable idea and something I thought of doing in the past. The reason it hasn't happened yet, is that MemoryFS is used extensively in tests - in fact, that is the main use case - and it if often useful not to have to carry variable handles around.
would only be true if the filesystem is not cachable, otherwise you get the identical python object: fsspec.filesystem("memory") is fsspec.filesystem("memory").
fsspec.get_filesystem_class("memory").cachable is True
Activity
martindurant commentedon Aug 7, 2025
This is a reasonable idea and something I thought of doing in the past. The reason it hasn't happened yet, is that MemoryFS is used extensively in tests - in fact, that is the main use case - and it if often useful not to have to carry variable handles around.
Note that:
would only be true if the filesystem is not cachable, otherwise you get the identical python object:
fsspec.filesystem("memory") is fsspec.filesystem("memory").martindurant commentedon Aug 7, 2025
In short: if you can make the change and no tests fail (or can be easily fixed), let's do it. Note that the documentation will need to be updated.