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

Stephen J. Turnbull stephen at xemacs.org
Sat Feb 14 03:35:11 CET 2015


Victor Stinner writes:

 > *** Now the real question: is it useful to know the inode number
 > (st_ino) without the device number (st_dev)? ***
 > 
 > On POSIX, you can still get the st_dev from DirEntry.stat(), but it
 > always require a system call. So you loose the whole purpose of
 > DirEntry (no extra syscall).

True, but I suppose in many cases the user will know that all file
system objects handled are on the same device, or will be willing to
risk an occasional anomoly.

IMO: Document the limitation (if no extra syscall) or inefficiency
(with the syscall), and let the user choose.

The remaining issue is whether to provide a convenience function for
the device number, with appropriately loud warnings about how
inefficient it is, or to deter the user with the need to call .stat()
and extract the device number.




More information about the Python-Dev mailing list