[Python-Dev] Updates to PEP 471, the os.scandir() proposal (original) (raw)
Ethan Furman ethan at stoneleaf.us
Thu Jul 10 02:38:11 CEST 2014
- Previous message: [Python-Dev] Updates to PEP 471, the os.scandir() proposal
- Next message: [Python-Dev] Updates to PEP 471, the os.scandir() proposal
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 07/09/2014 05:15 PM, Victor Stinner wrote:
2014-07-09 17:29 GMT+02:00 Ben Hoyt <benhoyt at gmail.com>:
Would this not "break" the tree size script being discussed in the other thread, as it would follow links and include linked directories in the "size" of the tree? The gettreesize() function in the PEP would use: "if not entry.issymlink() and entry.isdir():". Note: First I wrote "if entry.isdir() and not entry.issymlink():", but this syntax is slower on Linux because isdir() has to call lstat().
Wouldn't it only have to call lstat if the entry was, in fact, a link?
There are only a few cases where you want to handle symlinks differently: archive (ex: tar), compute the size of a directory (ex: du does not follow symlinks by default, du -L follows them), remove a directory.
I agree with Victor here. If the entry is a link I would want to know if it was a link to a directory or a link to a file. If I care about not following sym links I can check is_symlink() (or whatever it's called).
--
Ethan
- Previous message: [Python-Dev] Updates to PEP 471, the os.scandir() proposal
- Next message: [Python-Dev] Updates to PEP 471, the os.scandir() proposal
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]