[Python-ideas] anyone need a frozenset or bytearray literal?

Serhiy Storchaka storchaka at gmail.com
Thu Jul 12 03:41:48 EDT 2018


12.07.18 02:25, Gregory P. Smith пише:
> (c) adding a .freeze() method to sets which would raise an exception if 
> the set's refcount were > 1 and would mutate the type of the set object 
> into a frozenset object in place.  refcount assertions are bad, not all 
> VMs need refcounts.  The concept of a method that can mutate the type of 
> the underlying object in place is... unpythonic.  even though 
> technically possible to implement within CPython.

It is just an implementation detail that set and frozenset use the same 
internal representation, and just have different types. But it is 
possible to implement more efficient representation for frozensets. I 
have some ideas and could implement them if Raymond allows.



More information about the Python-ideas mailing list