[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: gnulib-tool.py: Update TODO file
From: |
Collin Funk |
Subject: |
Re: gnulib-tool.py: Update TODO file |
Date: |
Sat, 23 Mar 2024 18:50:30 -0700 |
User-agent: |
Mozilla Thunderbird |
On 3/23/24 5:01 PM, Bruno Haible wrote:
> * Is os.walk() as efficient as the 'find' command? On some file systems,
> determining the type (file vs. directory) of a directory entry requires
> an extra stat() call; on others, it is no extra overhead. We can assume
> that the 'find' command is well optimized.
> The os.walk documentation says: "Changed in version 3.5: This function
> now calls os.scandir() instead of os.listdir(), making it faster by
> reducing the number of calls to os.stat()."
> Does it mean that os.walk is as fully optimized as the 'find' command?
> I can't tell without looking into the Python sources or making actual
> measurements.
Interesting. I wasn't considering that many factors. The comment is
nearly a decade old so I assumed that Python 2 / early Python 3 had an
excessively slow implementation.
> * There is only 1 'find' invocation per gnulib-tool invocation. It does
> not occur in a loop. Therefore it is not necessarily worth optimizing.
>
> Whereas the 'sed' invocation in GLFileSystem.py:382 is run in a loop.
Yes that makes sense.
Collin