[Python-Dev] Dropping bytes "support" in json

Antoine Pitrou solipsis at pitrou.net
Tue Apr 14 01:58:27 CEST 2009

Bob Ippolito <bob <at> redivi.com> writes:
> The output of json/simplejson dumps for Python 2.x is either an ASCII
> bytestring (default) or a unicode string (when ensure_ascii=False).
> This is very practical in 2.x because an ASCII bytestring can be
> treated as either text or bytes in most situations, isn't going to get
> mangled over any kind of encoding mismatch (as long as it's an ASCII
> superset), and skips an encoding step if getting sent over the wire..

Which means that the json module already deals with text rather than bytes,
apart from the optimization that pure ASCII text is returned as 8-bit strings.



More information about the Python-Dev mailing list