[Python-Dev] Status of the PEP 400? (deprecate codecs.StreamReader/StreamWriter)

Benjamin Peterson benjamin at python.org
Thu Jul 28 06:10:28 CEST 2011


2011/7/27 Guido van Rossum <guido at python.org>:
> On Wed, Jul 27, 2011 at 6:00 PM, Nick Coghlan <ncoghlan at gmail.com> wrote:
>> On Thu, Jul 28, 2011 at 9:38 AM, Guido van Rossum <guido at python.org> wrote:
>>>> Users of codecs.open() or users of codecs.Stream* classes?
>>>
>>> I would think both. Is there any reason to continue using codecs.open()?
>>
>> It's the easiest way to write Unicode friendly code that spans both 2.x and 3.x.
>
> Even on 2.6, where the io module exists?

io on 2.6 is fairly broken and dead slow. The advantage of codecs.open
is it hasn't changed in the very long time. It still has the same
reliable buggy behavior no matter what version you're on.

I don't see the problem with leaving codecs.open() to rot a few more
releases before deprecating it while leaving messaging in the docs
suggesting io.*.

>
>> The problem is that naive 2.x code will migrate to the optimised IO
>> stack automatically on the 2.x -> 3.x transition, while code that
>> tried to do the right thing has to be changed manually (either in 3.x
>> only, or by switching to the io module for 2.x as well) in order to
>> adjust for the differences in argument order.
>>
>> The idea behind changing codecs.open to be a wrapper around io.open
>> was to allow such code to switch to the new optimised IO stack as
>> easily as code that just uses the open builtin. If it's acceptable for
>> the builtin behaviour to change (far more substantially), why not
>> change codecs.open as well?
>
> Aren't the cases different? Using built-in open() just means you want
> to open a file in the default way. Using codecs.open() presumably
> means that you've thought about Unicode.
>
> TBH, I said I was only -0 on the PEP, and if the stream returned by
> codecs.open() in 3.3 is sufficiently compatible with the stream
> returned the same function returns in 3.2, I am okay with it. (Except
> I also want you to cut a trillion dollars from the non-military
> budget, without raising taxes. :-)

May I suggest you include the military budget? :)



-- 
Regards,
Benjamin


More information about the Python-Dev mailing list