Re: Don't use __slots__ (was Re: performance of dictionary lookup vs. object attributes)

2006-08-29 Thread Antoon Pardon
On 2006-08-27, Jacob Hallen [EMAIL PROTECTED] wrote: In article [EMAIL PROTECTED], Patrick Maupin [EMAIL PROTECTED] wrote: Unfortunately there is a side effect to slots. They change the behaviour of the objects that have slots in a way that can be abused by control freaks and static typing

Re: Don't use __slots__ (was Re: performance of dictionary lookup vs. object attributes)

2006-08-28 Thread Dieter Maurer
Patrick Maupin [EMAIL PROTECTED] writes on 26 Aug 2006 12:51:44 -0700: ... The only problem I personally know of is that the __slots__ aren't inherited, __slots__ *ARE* inherited, although the rules may be a bit complex. class B(object): ... __slots__ = ('f1', 'f2',) ... class C(B): pass

Re: Don't use __slots__ (was Re: performance of dictionary lookup vs. object attributes)

2006-08-28 Thread Patrick Maupin
Dieter Maurer wrote: Patrick Maupin [EMAIL PROTECTED] writes on 26 Aug 2006 12:51:44 -0700: ... The only problem I personally know of is that the __slots__ aren't inherited, __slots__ *ARE* inherited, although the rules may be a bit complex. Yes, I didn't write that correctly. What's

Re: Don't use __slots__ (was Re: performance of dictionary lookup vs. object attributes)

2006-08-27 Thread Jacob Hallen
In article [EMAIL PROTECTED], Patrick Maupin [EMAIL PROTECTED] wrote: I didn't actually sense any dander on your part, so it was probably a bit unfortunate that I chose to respond to that particular message. I do (rightly or wrongly) sense some dander on Aahz's part, and this was the second or

Re: Don't use __slots__ (was Re: performance of dictionary lookup vs. object attributes)

2006-08-27 Thread Patrick Maupin
Jacob Hallen wrote: Patrick Maupin [EMAIL PROTECTED] wrote: Also, as I noted, I _do_ use them on occasion, so if there really _are_ potential pitfalls there, I would like to understand exactly what they are, so my ears perk up whenever I notice a __slots__ discussion, but so far I have been

Re: Don't use __slots__ (was Re: performance of dictionary lookup vs. object attributes)

2006-08-26 Thread Patrick Maupin
[EMAIL PROTECTED] wrote: Aahz Taking a look at __slots__ is fine as long as you don't actually Aahz use them. Gabriel Why? http://groups.google.com/group/comp.lang.python/browse_thread/thread/451ad25f9c648404/f4ac2dfde32b16fd?lnk=stq=Python+__slots__+aahzrnum=2#f4ac2dfde32b16fd Skip

Re: Don't use __slots__ (was Re: performance of dictionary lookup vs. object attributes)

2006-08-26 Thread skip
Aahz Taking a look at __slots__ is fine as long as you don't actually Aahz use them. Gabriel Why? Skip http://groups.google.com/group/comp.lang.python/browse_thread/thread/451ad25f9c648404/f4ac2dfde32b16fd?lnk=stq=Python+__slots__+aahzrnum=2#f4ac2dfde32b16fd Patrick The

Re: Don't use __slots__ (was Re: performance of dictionary lookup vs. object attributes)

2006-08-26 Thread Jarek Zgoda
[EMAIL PROTECTED] napisaƂ(a): That said, It's not mentioned on the Python3.0 page of the wiki: http://wiki.python.org/moin/Python3.0 or in PEP 3000: http://www.python.org/dev/peps/pep-3000/ and I see no discussion about it in the Python 3000 mailing list archives:

Re: Don't use __slots__ (was Re: performance of dictionary lookup vs. object attributes)

2006-08-26 Thread Patrick Maupin
[EMAIL PROTECTED] wrote: Aahz Taking a look at __slots__ is fine as long as you don't actually Aahz use them. Gabriel Why? Skip

Re: Don't use __slots__ (was Re: performance of dictionary lookup vs. object attributes)

2006-08-26 Thread Patrick Maupin
Jarek Zgoda wrote: Having that said, should we hope __slots__ would disappear in (some) future (tomorrow?!, in next 10 microseconds?!)? Please, don't left us hopeless. Are you saying you _do_ hope that __slots__ disappear? Why? Regards, Pat --

Re: Don't use __slots__ (was Re: performance of dictionary lookup vs. object attributes)

2006-08-26 Thread Carl Banks
Patrick Maupin wrote: The only assertion that was made explicitly enough to be testable came about in a followup to Aahz's original post, only AFTER someone asked what the side-effects associated with __slots__ were. Aahz responded: The main one is that inheritance becomes difficult to

Don't use __slots__ (was Re: performance of dictionary lookup vs. object attributes)

2006-08-25 Thread Aahz
In article [EMAIL PROTECTED], [EMAIL PROTECTED] wrote: Andre Meyer: Is the test meaningful and are you surprised by the results? I am, actually, because I would have assumed that attribute access with an object should be faster because lookup can be precompiled. The results seem okay. Python

Re: Don't use __slots__ (was Re: performance of dictionary lookup vs. object attributes)

2006-08-25 Thread Gabriel Genellina
At Friday 25/8/2006 11:34, Aahz wrote: The results seem okay. Python is a dynamic language, object attributes (and methods, etc) are kept inside a dict, where you can add and remove them when you like. So using a dict is faster. You can also take a look at __slots__ Taking a look at __slots__

Re: Don't use __slots__ (was Re: performance of dictionary lookup vs. object attributes)

2006-08-25 Thread skip
Aahz Taking a look at __slots__ is fine as long as you don't actually Aahz use them. Gabriel Why? http://groups.google.com/group/comp.lang.python/browse_thread/thread/451ad25f9c648404/f4ac2dfde32b16fd?lnk=stq=Python+__slots__+aahzrnum=2#f4ac2dfde32b16fd Skip --

Re: Don't use __slots__ (was Re: performance of dictionary lookup vs. object attributes)

2006-08-25 Thread bearophileHUGS
Aahz wrote: Taking a look at __slots__ is fine as long as you don't actually use them. I remember the recent discussion about such matters... but I don't understand its dangers fully still. I assume __slots__ may be removed in Python 3.0, but maybe experts need it now an then. Or maybe a experts