[Python-Dev] Allowing u.encode() to return non-strings
"Martin v. Löwis"
martin at v.loewis.de
Thu Jul 1 23:45:52 CEST 2004
Bill Janssen wrote:
> I assume, though, that the args to "read()" and friends are still
> about bytes.
Yes. It is not possible to determine, in advance, the number of
bytes needed to decode a given number of characters. Therefore, a
codec typically needs to either read more bytes than requested,
or return less characters (if the bytes read don't happen to
end on a character boundary).
So the size parameter to .read() is just a hint - a codec might
chose to completely ignore it.
Regards,
Martin
More information about the Python-Dev
mailing list