dicts vs classes

Nick Vatamaniuc vatamane at gmail.com
Tue Jul 25 14:52:57 EDT 2006


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 use it then why worry about it and to find out if it
is slower run a quick benchmark and you'll know...
-NickV

bearophileHUGS at lycos.com wrote:
> 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 you don't need the functionality supplied by objects, then using
> simpler dictionaries is better. (But in the end the choice has to be
> made according to the specific situations).
> 
> Bye,
> bearophile




More information about the Python-list mailing list