[prev in list] [next in list] [prev in thread] [next in thread] 

List:       python-patches
Subject:    [Patches] [ python-Patches-786237 ] os.path.exists should use
From:       noreply () sourceforge ! net (SourceForge ! net)
Date:       2003-08-31 12:55:21
Message-ID: E19tVTs-0007Ys-00 () sc8-sf-web3 ! sourceforge ! net
[Download RAW message or body]

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

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic