[Python-ideas] duck typing for io write methods
Terry Reedy
tjreedy at udel.edu
Sun Jun 16 12:11:07 CEST 2013
On 6/15/2013 1:12 PM, Paul Moore wrote:
> On 15 June 2013 17:51, Wolfgang Maier
> <wolfgang.maier at biologie.uni-freiburg.de
> <mailto:wolfgang.maier at biologie.uni-freiburg.de>>
> wrote:
>
> So if I understand the PEP correctly, then, theoretically, text mode
> file IO
> objects could be implemented to declare that all they'll ever need
> is 1 byte
> strings (if the encoding is ASCII-compatible)?
>
>
> There's no need to "declare" anything - if the file does not contain
> code points outside the 1-byte range, it just works. No declaration needed.
>
> The changes in the PEP are entirely transparent to the user, they just
> magically make your code faster if possible :-)
Some string operations are faster, some slower. Everyone will see either
a big space saving or perhaps a space saving and an end to 'bugs' due to
the use of surrogates. Everyone will see the same string behavior on all
platforms.
--
Terry Jan Reedy
More information about the Python-ideas
mailing list