[Python-ideas] Adding 'bytes' as alias for 'latin_1' codec.

Terry Reedy tjreedy at udel.edu
Thu May 26 06:09:42 CEST 2011

On 5/25/2011 10:57 PM, INADA Naoki wrote:
> Bytes supports some string methods.
As exactly specified in 4.6.5. Bytes and Byte Array Methods
There is really no need to repeat what everyone reading this knows.

 > I wrote
>> with open('tem.py', 'rb') as fin, open('tem2.txt', 'wb') as fout:
>>   for n, L in enumerate(fin):
>>     fout.write('{0:5d}\t'.format(n).encode('ascii'))
>>     fout.write(L)
>> (sys.x.fineno raises fineno AttributeError in IDLE.)
> There are 2 problems.
> 1) binary mode doesn't support line buffering. So I should disable buffering
>      and this may cause performance regression.

*nix already has a c-coded cat command; Windows has copy commands.
So there is no need to design Python for this.
Cat is usually used with files rather than terminals ans screens.
When it is used with terminals and screens, the extra encode/decode does 
not matter.
Realistic Python programs that actually do something with the text  need 
to decode with the actual encoding, regardless of byte source.
So I do not think we need a bytes alias for latin_1.
The docs might mention that it is essentially a do-nothing codec.

Terry Jan Reedy

More information about the Python-ideas mailing list