[Python-Dev] PEP 471 (scandir): Add a new DirEntry.inode() method?

Nick Coghlan ncoghlan at gmail.com
Sat Feb 14 10:13:42 CET 2015


On 14 Feb 2015 13:17, "Cameron Simpson" <cs at zip.com.au> wrote:
>
> -1 on that. People will use it! Given the doco above, it should be
obvious under what circumstances one might choose to call stat, and making
that stat overt means it is less likely to be called unwisely.
>
> Since scandir is all about efficiency, providing a very costly
convenience function seems to go against the grain.
>
> Regarding usefulness: Victor, you've got the typical use case in another
post (i.e. useful as in "advantageous"), and your own tests show that
st_dev of the dir matches st_dev of a dir's entries in all normal/regular
filesystems (i.e.  useful as in "meaningful/consistent").  Special
filesystems like /dev may be weird, but people relying on this should be
aware of the constraint anyway.  Since a directory at the low level is
essentially a mapping of names to inodes within the directory's filesystem,
this is to be expected.

+1 from me for Cameron's perspective & rationale - it's useful for
detecting hardlinks, it will usually work, and the cases where it isn't
sufficient on its own are filesystem handling edge cases in more ways than
one.

Cheers,
Nick.

>
> Cheers,
> Cameron Simpson <cs at zip.com.au>
>
> Uh, this is only temporary...unless it works.   - Red Green
>
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe:
https://mail.python.org/mailman/options/python-dev/ncoghlan%40gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20150214/b00c7618/attachment-0001.html>


More information about the Python-Dev mailing list