[Python-3000] Immutable bytes type and dbm modules

Guido van Rossum guido at python.org
Tue Aug 7 18:35:00 CEST 2007


On 8/7/07, Collin Winter <collinw at gmail.com> wrote:
> Could someone please explain to me the conceptual difference between
> array.array('B'), bytes(), buffer objects and simple lists of
> integers? I'm confused about when I should use which.

Assuming you weren't being sarcastic, array('B') and bytes() are very
close except bytes have a literal notation and many string-ish
methods. The buffer objects returned by the buffer() builtin provide a
read-only view on other objects that happen to have an internal
buffer, like strings, bytes, arrays, PIL images, and numpy arrays.
Lists of integers don't have the property that the other three share
which is that their C representation is a contiguous array of bytes
(char* in C). This representation is important because to do efficient
I/O in C you need char*.

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-3000 mailing list