Re: [Python-Dev] __getattr__ and new style classes

2008-10-09 Thread Brett Cannon
On Thu, Oct 9, 2008 at 5:37 PM, Greg Ewing <[EMAIL PROTECTED]> wrote: > Amaury Forgeot d'Arc wrote: > >> But this is already the case, and the reason why there are three >> variable to describe an exception: type, value and traceback. > > Yes, but you only get one object for the value, which means

Re: [Python-Dev] __getattr__ and new style classes

2008-10-09 Thread Greg Ewing
Amaury Forgeot d'Arc wrote: But this is already the case, and the reason why there are three variable to describe an exception: type, value and traceback. Yes, but you only get one object for the value, which means at least allocating a tuple if you want to be able to report something like "At

Re: [Python-Dev] __getattr__ and new style classes

2008-10-09 Thread Amaury Forgeot d'Arc
Hello, On Fri, Oct 10, 2008 at 2:15 AM, Greg Ewing <[EMAIL PROTECTED]> wrote: > Nick Coghlan wrote: > >> If the time is being spent in PyErr_Format, how far could you get adding >> a dedicated function for creating AttributeErrors? Something along the >> lines of: >> >> PyErr_AttributeError(PyObje

Re: [Python-Dev] __getattr__ and new style classes

2008-10-09 Thread Greg Ewing
Nick Coghlan wrote: If the time is being spent in PyErr_Format, how far could you get adding a dedicated function for creating AttributeErrors? Something along the lines of: PyErr_AttributeError(PyObject *object, PyObject *attr_name) More generally, it might be useful to have some mechanism f

Re: [Python-Dev] __getattr__ and new style classes

2008-10-09 Thread Kristján Valur Jónsson
to:[EMAIL PROTECTED] > Sent: Thursday, October 09, 2008 11:54 > To: Kristján Valur Jónsson > Cc: Python-Dev > Subject: Re: [Python-Dev] __getattr__ and new style classes > > Kristján Valur Jónsson wrote: > > Running regular python code through a profiler, and especially cod

Re: [Python-Dev] __getattr__ and new style classes

2008-10-09 Thread Nick Coghlan
Kristján Valur Jónsson wrote: > Running regular python code through a profiler, and especially code that > relies much on the use of > __getattr__() to emulate attribute access, will show hideous amounts of time > spent formatting > attribute exceptions that get thrown away. > > Any thoughts on

Re: [Python-Dev] __getattr__ and new style classes

2008-10-09 Thread Nick Coghlan
Christian Heimes wrote: > Nick Coghlan wrote: >> I think it's actually some single quotes that got mangled by the mailer. >> Either way, something else is going on for Kristján to see such wildly >> different results between old-style and new-style attribute access, when >> the differences are in t

Re: [Python-Dev] __getattr__ and new style classes

2008-10-09 Thread Christian Heimes
Nick Coghlan wrote: I think it's actually some single quotes that got mangled by the mailer. Either way, something else is going on for Kristján to see such wildly different results between old-style and new-style attribute access, when the differences are in the noise for the other folks checkin

Re: [Python-Dev] __getattr__ and new style classes

2008-10-09 Thread Kristján Valur Jónsson
No, it was really me being sloppy using outlook and fighting the editor trying to insert smart quotes :) Sorry for the confusion. K > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf > Of Christian Heimes > Kristján is using the old style and alternative

Re: [Python-Dev] __getattr__ and new style classes

2008-10-09 Thread Kristján Valur Jónsson
5 0.186524222345 patch active: 0.352850669641 0.147599760073 0.0910020300097 1.4453737036 0.212842069748 0.203442097864 Cheers, Kristján > -Original Message- > From: Nick Coghlan [mailto:[EMAIL PROTECTED] > Sent: Wednesday, October 08, 2008 21:37 > To: Kristján Valur Jónsson > Cc: Py

Re: [Python-Dev] __getattr__ and new style classes

2008-10-09 Thread Nick Coghlan
Christian Heimes wrote: > Steven D'Aprano wrote: >> Not only don't I observe the same results as you, I'm afraid I can't >> even get your code to run. I get a SyntaxError from the funny quotes >> you're using: ´d.foo´ instead of 'd.foo' or "d.foo". > > Kristján is using the old style and alternati

Re: [Python-Dev] __getattr__ and new style classes

2008-10-08 Thread Greg Ewing
Kristján Valur Jónsson wrote: Using new style classes to provide attribute-like access using __getattr__ is considerably slower than old style classes Do you really need __getattr__, or could you use properties instead? -- Greg ___ Python-Dev mailin

Re: [Python-Dev] __getattr__ and new style classes

2008-10-08 Thread Christian Heimes
Steven D'Aprano wrote: Not only don't I observe the same results as you, I'm afraid I can't even get your code to run. I get a SyntaxError from the funny quotes you're using: ´d.foo´ instead of 'd.foo' or "d.foo". Kristján is using the old style and alternative syntax for repr(). Somehow the

Re: [Python-Dev] __getattr__ and new style classes

2008-10-08 Thread Steven D'Aprano
On Thu, 9 Oct 2008 06:27:06 am Kristján Valur Jónsson wrote: > Hello there. > I've just noticed what I consider a performance problem: > Using new style classes to provide attribute-like access using > __getattr__ is considerably slower than old style classes: Observe: > > s = """ > class dude: >

Re: [Python-Dev] __getattr__ and new style classes

2008-10-08 Thread Nick Coghlan
Kristján Valur Jónsson wrote: > Hello there. > > I‘ve just noticed what I consider a performance problem: > > Using new style classes to provide attribute-like access using > __getattr__ is considerably slower than old style classes: Observe: I can't reproduce those relative numbers using SVN t

[Python-Dev] __getattr__ and new style classes

2008-10-08 Thread Kristján Valur Jónsson
Hello there. I've just noticed what I consider a performance problem: Using new style classes to provide attribute-like access using __getattr__ is considerably slower than old style classes: Observe: s = """ class dude: def bar(self):pass def __getattr__(self, a): return a class