Re: [Python-Dev] __file__ is not always an absolute path

2010-02-17 Thread Baptiste Lepilleur
I did some quick measures out of curiosity. Performances seems clearly filesystem and O.S. dependent (and are likely deployment/configuration dependent). I did each test 3 times to ensure measure where consistent. Tests were done with ActivePython 2.6.3.7. * AIX 5.3: python26 -m timeit -s 'def f(

Re: [Python-Dev] __file__ is not always an absolute path

2010-02-17 Thread Dan Villiom Podlaski Christiansen
On 7 Feb 2010, at 05:27, exar...@twistedmatrix.com wrote: > Do you know of a case where it's actually slow? If not, how convincing > should this argument really be? Perhaps we can measure it on a few platforms > before passing judgement. On Mac OS X at least, system calls are notoriously slow

Re: [Python-Dev] __file__ is not always an absolute path

2010-02-08 Thread Floris Bruynooghe
On Mon, Feb 08, 2010 at 12:51:22PM +, Antoine Pitrou wrote: > Do some people actually rely on the fact that changing the current directory > will also change the import path? On the interactive prompt, yes. But I guess that's a habit that could be easily un-learnt. Regards Floris -- Debi

Re: [Python-Dev] __file__ is not always an absolute path

2010-02-08 Thread Nick Coghlan
Antoine Pitrou wrote: > Nick Coghlan gmail.com> writes: >> The problem is that having '' as the first entry in sys.path currently >> means "do the import relative to the current directory". Unless we want >> to change the language semantics so we stick os.getcwd() at the front >> instead of '', th

Re: [Python-Dev] __file__ is not always an absolute path

2010-02-08 Thread Antoine Pitrou
Nick Coghlan gmail.com> writes: > > The problem is that having '' as the first entry in sys.path currently > means "do the import relative to the current directory". Unless we want > to change the language semantics so we stick os.getcwd() at the front > instead of '', then __file__ is still goin

Re: [Python-Dev] __file__ is not always an absolute path

2010-02-08 Thread Nick Coghlan
Antoine Pitrou wrote: > Barry Warsaw python.org> writes: >>> exarkun boson:~$ python -m timeit -s 'from os import getcwd' 'getcwd()' >>> 100 loops, best of 3: 1.02 usec per loop > [...] >> I'd like to see the effect on command line scripts that are run often and >> then >> exit, e.g. Bazaar

Re: [Python-Dev] __file__ is not always an absolute path

2010-02-07 Thread Antoine Pitrou
Barry Warsaw python.org> writes: > > >exarkun boson:~$ python -m timeit -s 'from os import getcwd' 'getcwd()' > >100 loops, best of 3: 1.02 usec per loop [...] > > I'd like to see the effect on command line scripts that are run often and then > exit, e.g. Bazaar or Mercurial. Start up time

Re: [Python-Dev] __file__ is not always an absolute path

2010-02-07 Thread Barry Warsaw
On Feb 06, 2010, at 11:22 PM, exar...@twistedmatrix.com wrote: >>I haven't tried to repro this particular example, but the reason is >>that we don't want to have to call getpwd() on every import nor do we >>want to have some kind of in-process variable to cache the current >>directory. (getpwd() i

Re: [Python-Dev] __file__ is not always an absolute path

2010-02-06 Thread exarkun
On 6 Feb, 11:53 pm, gu...@python.org wrote: On Sat, Feb 6, 2010 at 3:22 PM, wrote: On 10:29 pm, gu...@python.org wrote: [snip] I haven't tried to repro this particular example, but the reason is that we don't want to have to call getpwd() on every import nor do we want to have some kind of

Re: [Python-Dev] __file__ is not always an absolute path

2010-02-06 Thread Guido van Rossum
On Sat, Feb 6, 2010 at 4:36 PM, Christian Heimes wrote: > Guido van Rossum schrieb: >> Are you sure you remember this right? The .co_filename >> attributes will be unmarshalled straight from the bytecode file which >> indeed will have the relative path in this case (hopefully we'll >> finally fix

Re: [Python-Dev] __file__ is not always an absolute path

2010-02-06 Thread Christian Heimes
Guido van Rossum schrieb: > Are you sure you remember this right? The .co_filename > attributes will be unmarshalled straight from the bytecode file which > indeed will have the relative path in this case (hopefully we'll > finally fix this in 3.2 and 2.7). But if I read the code in import.c > corr

Re: [Python-Dev] __file__ is not always an absolute path

2010-02-06 Thread Guido van Rossum
On Sat, Feb 6, 2010 at 4:04 PM, Christian Heimes wrote: > Guido van Rossum wrote: >> What we do instead, is code in site.py that walks over the elements of >> sys.path and turns them into absolute paths. However this code runs >> before '' is inserted in the front of sys.path, so that the initial

Re: [Python-Dev] __file__ is not always an absolute path

2010-02-06 Thread Christian Heimes
Guido van Rossum wrote: > What we do instead, is code in site.py that walks over the elements of > sys.path and turns them into absolute paths. However this code runs > before '' is inserted in the front of sys.path, so that the initial > value of sys.path is ''. > > You may want to print the valu

Re: [Python-Dev] __file__ is not always an absolute path

2010-02-06 Thread Guido van Rossum
On Sat, Feb 6, 2010 at 3:22 PM, wrote: > On 10:29 pm, gu...@python.org wrote: >> >> On Sat, Feb 6, 2010 at 12:49 PM, Ezio Melotti >> wrote: >>> >>> In #7712 I was trying to change regrtest to always run the tests in a >>> temporary CWD (e.g. /tmp/@test_1234_cwd/). >>> The patches attached to the

Re: [Python-Dev] __file__ is not always an absolute path

2010-02-06 Thread exarkun
On 10:29 pm, gu...@python.org wrote: On Sat, Feb 6, 2010 at 12:49 PM, Ezio Melotti wrote: In #7712 I was trying to change regrtest to always run the tests in a temporary CWD (e.g. /tmp/@test_1234_cwd/). The patches attached to the issue add a context manager that changes the CWD, and it works

Re: [Python-Dev] __file__ is not always an absolute path

2010-02-06 Thread Guido van Rossum
On Sat, Feb 6, 2010 at 12:49 PM, Ezio Melotti wrote: > In #7712 I was trying to change regrtest to always run the tests in a > temporary CWD (e.g. /tmp/@test_1234_cwd/). > The patches attached to the issue add a context manager that changes the > CWD, and it works fine when I run ./python -m test.