Problem of Readability of Python
Bjoern Schliessmann
usenet-mail-0306.20.chr0n0ss at spamgourmet.com
Sun Oct 7 14:26:53 EDT 2007
Licheng Fang wrote:
> struct nameval {
> char * name;
> int val;
> } a;
>
> a.name = ...
> a.val = ...
>
> becomes cryptic
>
> a[0] = ...
> a[1] = ...
?!
(1)
a = {}
a["name"] = ...
a["val"] = ...
(2)
NAME = 0
VAL = 1
a=[]
a[NAME] = ...
a[VAL] = ...
> Python Tutorial says an empty class can be used to do this. But if
> namespaces are implemented as dicts, wouldn't it incur much
> overhead if one defines empty classes as such for some very
> frequently used data structures of the program?
Measure first, optimize later. How many million of instances and/or
accesses per second do you have?
Regards,
Björn
--
BOFH excuse #20:
divide-by-zero error
More information about the Python-list
mailing list