Can't do a multiline assignment!

Bruno Desthuilliers bruno.42.desthuilliers at websiteburo.invalid
Fri Apr 18 05:28:36 EDT 2008


s0suk3 at gmail.com a écrit :
> On Apr 17, 12:34 pm, Michael Torrie <torr... at gmail.com> wrote:
>> Another thing to consider is that referencing a member of a class or
>> instance already *is* a dictionary lookup.  It's how python works.  Thus
>> dictionaries are optimized to be fast.  Since strings are immutable,
>> python hashes them into a fast lookup pointer.  So every time you say
>> mydict["mykey"], it already knows the lookup pointer (hash) for "mykey"
>> (the string) and can find the dictionary entry very quickly, ideally in
>> O(1) time (well maybe log(N)).  Thus putting your headers in a
>> dictionary is actually a really good idea for performance reasons.
> 
> I didn't know about that, thanks. So after all the trouble I went
> through writing those 200 loc I actually maid it worse...

That's an understatement.



More information about the Python-list mailing list