[Python-ideas] Add encoding attribute to bytes

Nick Coghlan ncoghlan at gmail.com
Fri Nov 6 10:13:26 CET 2009


Terry Reedy wrote:
> Bytes are nearly always an encoding of *something*, but the particular
> encoding used is instance-specific. As Guido has said, the programmer
> must keep track. But how? In an OO language, one obvious way is as an
> attribute of the instance. That would be carried with the instance and
> make it self-identifying.

I work in comms and spend a lot of time shuttling bytes from one place
to another without caring in the least about the encoding. Caring about
that kind of detail is application layer stuff and belongs in
application layer objects.

More importantly, such an attribute implies a defined responsibility for
keeping it accurate. For application layer objects, it is possible to
define that. For a low level data structure like bytes, it isn't.

Attaching metadata to something without defining a responsible entity
for keeping that metadata accurate and up to date is a recipe for trouble.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------



More information about the Python-ideas mailing list