String or tuple and unions
phr-n2003b at NOSPAMnightsong.com
Sun Feb 9 21:55:14 CET 2003
Grumfish <nobody at nowhere.com> writes:
> Which is faster to read from, a string or a tuple? All items would be
> 1 unicode character and I would be mostly treating the string as a
> tuple, only looking for items.
> Two more questions, is there a way to find the union of two sets? And
> how fast does the len() function work? Would it be worth my while to
> store the length of a large string (or tuple) instad of using len
> several times?
Do you mean the new set objects in 2.3? They are just basically dicts.
If you mean strings and tuples, the len function is fast. The length
is stored in the data structure--the len function just returns it.
It doesn't go count the items one by one.
More information about the Python-list