Re: Don't use __slots__! (was Re: dicts vs classes)

2006-07-28 Thread Aahz
In article [EMAIL PROTECTED], Roy Smith [EMAIL PROTECTED] wrote: Guido sez: __slots__ is a terrible hack with nasty, hard-to-fathom side effects that should only be used by programmers at grandmaster and wizard levels. Unfortunately it has gained an enormous undeserved

dicts vs classes

2006-07-25 Thread Guyon Morée
Hi all, I'm using simple classes as a container of named values and I'm instantiating a lot of them in a very short time. i was wondering if there is any benefit in using dicts instead from a performance/memory usage point of view? regards, Guyon Morée http://gumuz.looze.net --

Re: dicts vs classes

2006-07-25 Thread Marc 'BlackJack' Rintsch
In [EMAIL PROTECTED], Guyon Morée wrote: I'm using simple classes as a container of named values and I'm instantiating a lot of them in a very short time. i was wondering if there is any benefit in using dicts instead from a performance/memory usage point of view? If you really have a

Re: dicts vs classes

2006-07-25 Thread Marco Wahl
Guyon Morée [EMAIL PROTECTED] writes: I'm using simple classes as a container of named values and I'm instantiating a lot of them in a very short time. i was wondering if there is any benefit in using dicts instead from a performance/memory usage point of view? I recommend you to measure

Re: dicts vs classes

2006-07-25 Thread Pan Xingzhi
dict is already a classwhy another? Guyon Morée wrote: Hi all, I'm using simple classes as a container of named values and I'm instantiating a lot of them in a very short time. i was wondering if there is any benefit in using dicts instead from a performance/memory usage point of

Re: dicts vs classes

2006-07-25 Thread Simon Hibbs
I'm wondering about whether to use objects in this way or dictionaries for a program I'm writing at the moment. It seems to me that unless you need some of the functionality supplied with dictionaries (len(a), has_key, etc) then simple objects are a syntacticaly cleaner and more natural way to

Don't use __slots__! (was Re: dicts vs classes)

2006-07-25 Thread Aahz
In article [EMAIL PROTECTED], Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote: In [EMAIL PROTECTED], Guyon Morée wrote: I'm using simple classes as a container of named values and I'm instantiating a lot of them in a very short time. i was wondering if there is any benefit in using dicts

Re: dicts vs classes

2006-07-25 Thread bearophileHUGS
Simon Hibbs: It seems to me that unless you need some of the functionality supplied with dictionaries (len(a), has_key, etc) then simple objects are a syntacticaly cleaner and more natural way to express yourself. I'd say the opposite. Classes contain a dict of their attributes, etc. So if

Re: Don't use __slots__! (was Re: dicts vs classes)

2006-07-25 Thread bearophileHUGS
Aahz, citing Guido: __slots__ is a terrible hack with nasty, hard-to-fathom side effects that should only be used by programmers at grandmaster and wizard levels. Unfortunately it has gained an enormous undeserved I think I have used __slots__ just one time. Can you tell me some of of such bad

Re: dicts vs classes

2006-07-25 Thread Simon Forman
Simon Hibbs wrote: I'm wondering about whether to use objects in this way or dictionaries for a program I'm writing at the moment. It seems to me that unless you need some of the functionality supplied with dictionaries (len(a), has_key, etc) then simple objects are a syntacticaly cleaner and

Re: Don't use __slots__! (was Re: dicts vs classes)

2006-07-25 Thread Aahz
In article [EMAIL PROTECTED], [EMAIL PROTECTED] wrote: Aahz, citing Guido: __slots__ is a terrible hack with nasty, hard-to-fathom side effects that should only be used by programmers at grandmaster and wizard levels. Unfortunately it has gained an enormous undeserved I think I have used

Re: Don't use __slots__! (was Re: dicts vs classes)

2006-07-25 Thread Roy Smith
Guido sez: __slots__ is a terrible hack with nasty, hard-to-fathom side effects that should only be used by programmers at grandmaster and wizard levels. Unfortunately it has gained an enormous undeserved popularity amongst the novices and apprentices, who should know

Re: dicts vs classes

2006-07-25 Thread Nick Vatamaniuc
Don't optimize prematurely. Write whatever is cleaner, simpler and makes more sense. Such that if someone (or even yourself) looks at it 10 years from now they'll know exactly what is going on. As far as what is slower or what functionality you will use and what you won't -- well, if you won't