[issue39783] Optimize construction of Path from other Paths by just returning the same object?

Rémi Lapeyre report at bugs.python.org
Fri Feb 28 16:41:52 EST 2020


Rémi Lapeyre <remi.lapeyre at henki.fr> added the comment:

> Decorating __new__ with lru_cache would likely run into memory leakage problems?

I think the LRU cache would be for returning the same instance when called with the same string. I don't think it would be needed to return the same instance when called with a Path instance.

> From a quick look it appears to only be settable by using the path (not the actual file) as a context manager, and only serves to block further filesystem methods, but I'm not even sure why?

This came up in bpo-39682 recently, I'm not sure what this flag is supposed to mean and I could not find it in the documentation.

Since it's uncorrelated to the file object and the physical file, I think it may actually be dangerous to rely on this flag. I don't know why is the purpose of using Path as a context manager.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39783>
_______________________________________


More information about the Python-bugs-list mailing list