Martin v. Löwis wrote:
>> The most efficient representation of immutable bytes is quite different
>> from the most efficient representation of mutable bytes.
> 
> In what way?

Well, in some runtime environments (I'm not sure about Python), for 
immutables you can combine the object header and the bytes array into a 
single allocation. Further, the header need not contain an explicit 
pointer to the bytes themselves, instead the bytes are obtained by doing 
pointer arithmetic on the header address.

For a mutable bytes object, you'll need to allocate the actual bytes 
separately from the header. Typically you'll also need a second 'length' 
field to represent the current physical capacity of the allocated memory 
block, in addition to the logical length of the byte array.

So in other words, the in-memory layout of the two structs is different 
enough that attempting to combine them into a single struct is kind of 
awkward.

> Curious,
> Martin
> 
_______________________________________________
Python-3000 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to