frozenset question

Will McGugan news at NOwillmcguganSPAM.com
Wed Jul 6 09:25:30 EDT 2005


Steven D'Aprano wrote:

> There is no significant speed difference between immutable and mutable
> sets, at least for queries. Regardless of whether it is successful or
> unsuccessful, mutable or immutable, it takes about 0.0000025 second to do
> each test of item in set. Why would you need to optimize that?
> 
> If you tell us what you are trying to do, and under what circumstances it
> is too slow, we'll see if we can suggest some ways to optimize it.
> 
> But if you are just trying to optimize for the sake of optimization,
> that's a terrible idea. Get your program working first. Then when it
> works, measure how fast it runs. If, and ONLY if, it is too slow, 
> identify the parts of the program that make it too slow. That means
> profiling and timing. Then optimize those parts, and nothing else.
> 
> Otherwise, you will be like the car designer trying to speed up his sports
> cars by making the seatbelts aerodynamic.

No need for the 'premature optimization is the root of all evil' speech. 
I'm not trying to optimize anything - just enquiring about the nature of 
frozenset. If typing 'frozenset' over 'set' gave me a saving in time or 
memory (even if tiny) I would favour immutable sets, where appropriate.

Thanks for the info.

Will

-- 
http://www.willmcgugan.com
"".join({'*':'@','^':'.'}.get(c,0) or chr(97+(ord(c)-84)%26) for c in 
"jvyy*jvyyzpthtna^pbz")



More information about the Python-list mailing list