2014-07-21 18:48 GMT+02:00 Ben Hoyt <benh...@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.stat_result() 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 clear_cache() 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 clear_cache() method -- basically it'd set > _lstat and _stat and _d_type to None internally. However, I'd prefer > to keep it as is, and as the PEP says: (...) Ok, agreed. Victor _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com