[Python-3000] Immutable bytes type and dbm modules
g.brandl at gmx.net
Wed Aug 8 08:38:11 CEST 2007
Jim Jewett schrieb:
> On 8/7/07, Guido van Rossum <guido at python.org> wrote:
>> If b"..." is immutable, the
>> immutable bytes type is in your face all the time and you'll have to
>> deal with the difference all the time.
> There is a conceptual difference between the main use cases for
> mutable (a buffer) and the main use cases for immutable (a protocol
> I'm not sure why you would need a literal for the mutable version.
> How often do you create a new buffer with initial values? (Note: not
> pointing to existing memory; creating a new one.)
The same reason that you might create empty lists or dicts: to fill them.
>> E.g. is the result of
>> concatenating a mutable and an immutable bytes object mutable?
>> Does it matter whether the mutable operand is first or second?
> I would say immutable; you're taking a snapshot. (I would have some
> sympathy for taking the type of the first operand, but then you need
> to worry about + vs +=, and whether the start of the new object will
> notice later state changes.)
But what about
mutable = mutable + immutable
mutable += immutable
I'd expect it to stay mutable in both cases.
Thus spake the Lord: Thou shalt indent with four spaces. No more, no less.
Four shall be the number of spaces thou shalt indent, and the number of thy
indenting shall be four. Eight shalt thou not indent, nor either indent thou
two, excepting that thou then proceed to four. Tabs are right out.
More information about the Python-3000