[Python-3000] Bytes and unicode conversion in C extensions

Andrew McNamara andrewm at object-craft.com.au
Wed Jul 30 07:17:26 CEST 2008

>> What about a new keyword argument to the constructor, "encoding". If
>> specified, *only* accept unicode (and do the conversion internally).
>Would that apply to keys, values, or both?

I admit that I deliberately glossed over that. 8-)

One option is to say "both", just to keep it simple: if you're doing
something funky, use the "bytes" mode and do your own encoding.

Another option would be have "key_encoding" and "value_encoding" as well,
and let them default to "encoding". I'm not so keen on this.

I think the important point is to throw an exception if the module gets
input of the wrong type, rather than trying to coerce the input. Which
implies it needs to know what mode it's in.

Andrew McNamara, Senior Developer, Object Craft

More information about the Python-3000 mailing list