frozenset() without arguments should return a singleton

S

Stefan Behnel

Hi!

frozenset() doesn't behave as the other immutable empty data types in 2.4:

..>>> '' is ''
True
..>>> () is ()
True
..>>> frozenset() is frozenset()
False

..>>> id(()),id(())
(1077579820, 1077579820)
..>>> id(())
1077579820
..>>> id(frozenset()),id(frozenset())
(1077581296, 1077581296)
..>>> id(frozenset())
1077581440
..>>> id(frozenset(()))
1077582256

frozenset() called without arguments (or on empty sequences) should always
return a singleton object. It is immutable, so I can see no reason why it
should take up more resources than necessary.

Stefan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top