Can't do a multiline assignment!

Arnaud Delobelle arnodel at googlemail.com
Thu Apr 17 19:36:41 CEST 2008


On Apr 17, 6:02 pm, s0s... at gmail.com wrote:
[...]
> I do it with all the separate variables mainly for performance. If I
> had the headers in a dict, I'd be looking up a string in a list of
> strings (the keys of the dict) everytime I check for a header. Not
> that that's going to take more that 0.1 seconds, but the program is
> still small and simple. As it gets bigger, more features are gonna
> slow things down.

- Have you measured the difference in performance?

- Are you aware that attribute access is implemented as string lookup
in a dictionary?

i.e. when you write foo.bar, the interpreter looks for 'bar' in
foo.__dict__, and if it doesn't find it, then proceeds to look in
type(foo).__dict__.  So in your code, if a header (with manager rhm)
has no 'allow' field and you do:

    rhm.Allow

the interpreter looks up *two* dictionaries (rhm.__dict__ then
RequestHeadersManager.__dict__).

--
Arnaud


--
Arnaud




More information about the Python-list mailing list