[Patches] [ python-Patches-786237 ] os.path.exists should use
os.access when possible
SourceForge.net
noreply at sourceforge.net
Sun Aug 31 10:55:12 EDT 2003
Patches item #786237, was opened at 2003-08-10 15:03
Message generated for change (Comment added) made by loewis
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=786237&group_id=5470
Category: Library (Lib)
Group: None
>Status: Closed
>Resolution: Rejected
Priority: 5
Submitted By: Matthew Mueller (donut)
Assigned to: Nobody/Anonymous (nobody)
Summary: os.path.exists should use os.access when possible
Initial Comment:
Compared to os.access, os.stat is very slow (probably
due constructing to the stat object it returns).
Therefore, os.path.exists should use os.access instead,
when possible. (posixpath, I guess ntpath too.)
(I didn't include a patch for ntpath since I can't test
it.)
As a bonus, the code is cleaner too. :)
examples:
> touch file_that_exists
> python2.3 timeit.py -s "from os.path import exists"
"exists('file_that_exists')"
100000 loops, best of 3: 15.6 usec per loop
> python2.3 timeit.py -s "from newposixpath import
exists" "exists('file_that_exists')"
100000 loops, best of 3: 6.17 usec per loop
> python2.3 timeit.py -s "from os.path import exists"
"exists('file_that_does_not_exist')"
10000 loops, best of 3: 48.9 usec per loop
> python2.3 timeit.py -s "from newposixpath import
exists" "exists('file_that_does_not_exist')"
100000 loops, best of 3: 6.37 usec per loop
----------------------------------------------------------------------
>Comment By: Martin v. Löwis (loewis)
Date: 2003-08-31 18:55
Message:
Logged In: YES
user_id=21627
This patch is incorrect (rejecting it), see
http://mail.python.org/pipermail/python-dev/2002-June/025511.html
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=786237&group_id=5470
More information about the Patches
mailing list