[Python-Dev] Remaining decisions on PEP 471 -- os.scandir() (original) (raw)
Victor Stinner victor.stinner at gmail.com
Tue Jul 22 00:39:26 CEST 2014
- Previous message: [Python-Dev] Remaining decisions on PEP 471 -- os.scandir()
- Next message: [Python-Dev] Remaining decisions on PEP 471 -- os.scandir()
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
2014-07-21 18:48 GMT+02:00 Ben Hoyt <benhoyt at gmail.com>:
By the way, DirEntry constructor is not documented in the PEP. Should we document it? It might be a way to "invalidate the cache": I would prefer not to, just to keep things simple. Similar to creating os.statresult() objects ... you can kind of do it (see scandir.py), but it's not recommended or even documented. The entire purpose of DirEntry objects is so scandir can produce them, not for general use.
entry = DirEntry(os.path.dirname(entry.path), entry.name)
Maybe it is an abuse of the API. A clearcache() method would be less ugly :-) But maybe Ben Hoyt does not want to promote keeping DirEntry for a long time? Another question: should we expose DirEntry type directly in the os namespace? (os.DirEntry) Again, I'd rather not expose this. It's quite system-specific (see the different system versions in scandir.py), and trying to combine this, make it consistent, and document it would be a bit of a pain, and also possibly prevent future modifications (because then the parts of the implementation would be set in stone).
We should mimic os.stat() and os.stat_result: os.stat_result symbol exists in the os namespace, but the type constructor is not documented. No need for extra protection like not adding the type in the os module, or adding a "_" prefix to the name.
By the way, it's possible to serialize a stat_result with pickle.
See also my issue "Enhance doc of os.stat_result": http://bugs.python.org/issue21813
I'm not really opposed to a clearcache() method -- basically it'd set lstat and stat and dtype to None internally. However, I'd prefer to keep it as is, and as the PEP says: (...)
Ok, agreed.
Victor
- Previous message: [Python-Dev] Remaining decisions on PEP 471 -- os.scandir()
- Next message: [Python-Dev] Remaining decisions on PEP 471 -- os.scandir()
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]