
Johannes Gijsbers <jlgijsbers@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