[Python-3000] Immutable bytes type and dbm modules
talin at acm.org
Tue Aug 7 03:43:03 CEST 2007
Nick Coghlan wrote:
> Martin v. Löwis wrote:
>> I don't think it needs to be a separate type,
>> instead, bytes objects could have a idem-potent
>> .freeze() method which switches the "immutable"
>> bit on. There would be no way to switch it off
> +1 here - hashable byte sequences are very handy for dealing with
> fragments of low level serial protocols.
> It would also be nice if b"" literals set that immutable flag
> automatically - otherwise converting some of my lookup tables over to
> Py3k would be a serious pain (not a pain I'm likely to have to deal with
> personally given the relative time frames involved, but a pain nonetheless).
I'm also for an immutable bytes type - but I'm not so sure about
freezing in place.
The most efficient representation of immutable bytes is quite different
from the most efficient representation of mutable bytes.
Rather, I think that they should both share a common Abstract Base Class
defining what you can do with immutable byte strings, but the actual
storage of the bytes themselves should be implemented in the subclass.
More information about the Python-3000