Re: [Python-Dev] cpython (3.2): Fix #11583. Changed os.path.isdir to use GetFileAttributes instead of os.stat.

2011-06-09 Thread Victor Stinner
Le jeudi 09 juin 2011 à 08:16 +0200, Georg Brandl a écrit :
> On 06/09/11 02:00, brian.curtin wrote:
> > http://hg.python.org/cpython/rev/88e318166eaf
> > changeset:   70713:88e318166eaf
> > branch:  3.2
> > parent:  70700:0aa3064d1cef
> > user:Brian Curtin 
> > date:Wed Jun 08 18:17:18 2011 -0500
> > summary:
> >   Fix #11583. Changed os.path.isdir to use GetFileAttributes instead of 
> > os.stat.
> > 
> > By changing to the Windows GetFileAttributes API in nt._isdir we can figure
> > out if the path is a directory without opening the file via os.stat. This 
> > has
> > the minor benefit of speeding up os.path.isdir by at least 2x for regular
> > files and 10-15x improvements were seen on symbolic links (which opened the
> > file multiple times during os.stat). Since os.path.isdir is used in
> > several places on interpreter startup, we get a minor speedup in startup 
> > time.
> > 
> > files:
> >   Lib/ntpath.py |  13 ++
> >   Misc/NEWS |   3 ++
> >   Modules/posixmodule.c |  37 +++
> >   3 files changed, 53 insertions(+), 0 deletions(-)
> > 
> > 
> > diff --git a/Lib/ntpath.py b/Lib/ntpath.py
> > --- a/Lib/ntpath.py
> > +++ b/Lib/ntpath.py
> > @@ -672,3 +672,16 @@
> >  def sameopenfile(f1, f2):
> >  """Test whether two file objects reference the same file"""
> >  return _getfileinformation(f1) == _getfileinformation(f2)
> > +
> > +
> > +try:
> > +# The genericpath.isdir implementation uses os.stat and checks the mode
> > +# attribute to tell whether or not the path is a directory.
> > +# This is overkill on Windows - just pass the path to GetFileAttributes
> > +# and check the attribute from there.
> > +from nt import _isdir
> > +except ImportError:
> > +from genericpath import isdir as _isdir
> > +
> > +def isdir(path):
> > +return _isdir(path)
> 
> Not that it matters, but ISTM that this would be faster as
> 
> try:
> from nt import _isdir as isdir
> except ImportError:
> pass

I would matter if _isdir() had a docstring, but it doesn't :-)
genericpath.isdir() has the following doc:

def isdir(s):
"""Return true if the pathname refers to an existing directory."""

Victor

___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] 3.2.1 and Issue 12291

2011-06-09 Thread Vinay Sajip
I just filed an issue which shows a serious breakage in the marshal module:

"file written using marshal in 3.2 can be read by 2.7, but not 3.2 or 3.3"

http://bugs.python.org/issue12291

Perhaps this issue should be marked as a release blocker for 3.2.1 - what do
others (particularly Georg, of course) think? While it does appear to have been
broken for some time, it seems a bit too serious to leave until a 3.2.2 release.

Regards,

Vinay Sajip

___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Can we improve support for abstract base classes with desciptors

2011-06-09 Thread Darren Dale
On Wed, Jun 8, 2011 at 10:01 PM, Nick Coghlan  wrote:
> On Thu, Jun 9, 2011 at 8:51 AM, Darren Dale  wrote:
>>>       for base in bases:
>>>           for name in getattr(base, "__abstractmethods__", ()):
>>>               # CHANGE 4: Using rpartition better tolerates weird
>>> naming in the metaclass
>>>               # (weird naming in descriptors will still blow up in
>>> the earlier search for abstract names)
>>
>> Could you provide an example of weird naming?
>
 class C(object):
> ...   pass
> ...
 setattr(C, 'weird.name', staticmethod(int))
[...]

> This is definitely something that could legitimately be dismissed as
> "well, don't do that then" (particularly since similarly weird names
> on the descriptors will still break). However, I also prefer the way
> partition based code reads over split-based code, so I still like the
> modified version.

Yes, I like your modified version as well. I just wanted to understand
your concern, since it had never occurred to me to try something like
"setattr(C, 'pathological.name', ...)".

> Full tolerance for weird naming would require storing 2-tuples in
> __abstractmethods__ which would cause a whole new set of problems and
> isn't worth the hassle.

I'm glad you feel that way.

I'll work on a patch that includes docs and unit tests and post it at
http://bugs.python.org/issue11610. What do you think about deprecating
abstractproperty, or removing it from the documentation?

Darren
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Can we improve support for abstract base classes with desciptors

2011-06-09 Thread Nick Coghlan
On Thu, Jun 9, 2011 at 9:45 PM, Darren Dale  wrote:
> What do you think about deprecating
> abstractproperty, or removing it from the documentation?

Unless anyone specifically howls at the idea, +1 to both (since
abstractproperty doesn't actually achieve the intended purpose and
will become redundant with the proper fix in 3.3).

Cheers,
Nick.


-- 
Nick Coghlan   |   [email protected]   |   Brisbane, Australia
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] 3.2.1 and Issue 12291

2011-06-09 Thread Barry Warsaw
On Jun 09, 2011, at 10:51 AM, Vinay Sajip wrote:

>I just filed an issue which shows a serious breakage in the marshal module:
>
>"file written using marshal in 3.2 can be read by 2.7, but not 3.2 or 3.3"
>
>http://bugs.python.org/issue12291
>
>Perhaps this issue should be marked as a release blocker for 3.2.1 - what do
>others (particularly Georg, of course) think? While it does appear to have
>been broken for some time, it seems a bit too serious to leave until a 3.2.2
>release.

Sounds bad ;).  I marked it a release blocker, but of course Georg will have
the final say.

-Barry


signature.asc
Description: PGP signature
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] cpython (3.2): Fix #11583. Changed os.path.isdir to use GetFileAttributes instead of os.stat.

2011-06-09 Thread Brian Curtin
On Thu, Jun 9, 2011 at 04:05, Victor Stinner
wrote:

> Le jeudi 09 juin 2011 à 08:16 +0200, Georg Brandl a écrit :
> > On 06/09/11 02:00, brian.curtin wrote:
> > > http://hg.python.org/cpython/rev/88e318166eaf
> > > changeset:   70713:88e318166eaf
> > > branch:  3.2
> > > parent:  70700:0aa3064d1cef
> > > user:Brian Curtin 
> > > date:Wed Jun 08 18:17:18 2011 -0500
> > > summary:
> > >   Fix #11583. Changed os.path.isdir to use GetFileAttributes instead of
> os.stat.
> > >
> > > By changing to the Windows GetFileAttributes API in nt._isdir we can
> figure
> > > out if the path is a directory without opening the file via os.stat.
> This has
> > > the minor benefit of speeding up os.path.isdir by at least 2x for
> regular
> > > files and 10-15x improvements were seen on symbolic links (which opened
> the
> > > file multiple times during os.stat). Since os.path.isdir is used in
> > > several places on interpreter startup, we get a minor speedup in
> startup time.
> > >
> > > files:
> > >   Lib/ntpath.py |  13 ++
> > >   Misc/NEWS |   3 ++
> > >   Modules/posixmodule.c |  37 +++
> > >   3 files changed, 53 insertions(+), 0 deletions(-)
> > >
> > >
> > > diff --git a/Lib/ntpath.py b/Lib/ntpath.py
> > > --- a/Lib/ntpath.py
> > > +++ b/Lib/ntpath.py
> > > @@ -672,3 +672,16 @@
> > >  def sameopenfile(f1, f2):
> > >  """Test whether two file objects reference the same file"""
> > >  return _getfileinformation(f1) == _getfileinformation(f2)
> > > +
> > > +
> > > +try:
> > > +# The genericpath.isdir implementation uses os.stat and checks the
> mode
> > > +# attribute to tell whether or not the path is a directory.
> > > +# This is overkill on Windows - just pass the path to
> GetFileAttributes
> > > +# and check the attribute from there.
> > > +from nt import _isdir
> > > +except ImportError:
> > > +from genericpath import isdir as _isdir
> > > +
> > > +def isdir(path):
> > > +return _isdir(path)
> >
> > Not that it matters, but ISTM that this would be faster as
> >
> > try:
> > from nt import _isdir as isdir
> > except ImportError:
> > pass
>
> I would matter if _isdir() had a docstring, but it doesn't :-)
> genericpath.isdir() has the following doc:
>
> def isdir(s):
>"""Return true if the pathname refers to an existing directory."""


http://hg.python.org/lookup/d40609dd01e0 adds the docstring back in and
redoes the imports as Georg mentioned, which is better.
Thanks for having a look.
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com