frozenset() without arguments should return a singleton

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Stefan Behnel

    #1

    frozenset() without arguments should return a singleton

    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
Working...