[Python-3000] Immutable bytes type and dbm modules

Talin talin at acm.org
Fri Aug 10 06:39:12 CEST 2007


Joel Bender wrote:
> Jason Orendorff wrote:
> 
>> Hooks would help with that, or even eliminate the need altogether.
> 
> IMHO, having a __bytes__ method would go a long way.

This would be better done with generic functions once we have them.

I general, I feel it's better not to embed knowledge of a particular 
serialization scheme in an object. Otherwise, you'd end up with every 
class having to know about 'pickle' and 'shelve' and 'marshall' and 
'JSON' and 'serialize-to-XML' and every other weird serialization format 
that people come up with.

Instead, this is exactly what GFs are good for, so that neither the 
object nor the serializer have to handle the N*M combinations of the two.

Of course, this criticism also works against having a __str__ method, 
instead of simply defining 'str()' as a GF. And there is some validity 
to that point. But for historical reasons, we're not likely to change 
it. And there's also some validity to the argument that a 'printable' 
representation is the one universal converter that deserves special status.

-- Talin


More information about the Python-3000 mailing list