[Python-Dev] Re: Adding 'lexists()' to os.path
Paul Moore
pf_moore at yahoo.co.uk
Sun Aug 22 15:17:00 CEST 2004
Johannes Gijsbers <jlgijsbers at planet.nl> writes:
> I was just reviewing the patch at http://python.org/sf/941486, which proposes
> adding a new 'lexists()' function to os.path. This function would return True
> for dangling symbolic links, unlike os.path.exists() which returns False. One
> could use 'os.path.islink(path) or os.path.exists()' as well, but that's two
> stat calls instead of one.
As an alternative, would there be any value in cacheing the last stat
result? In a sequence like this, with multiple calls for the same
argument, many stat calls would be replaced by one. And it's likely
that the checking overhead on cache misses would be minimal compared
to the cost of the stat call, so it's an overall win.
Of course, actual tests beat idle speculation like this...
Paul.
--
Any sufficiently advanced technology is indistinguishable from magic.
-- Arthur C. Clarke
More information about the Python-Dev
mailing list