Raymond Hettinger <raymond.hettin...@gmail.com> added the comment:

[Mark Dickinson]
> I'd also really like to avoid a system-dependent default.

[Petr Viktorin]
> Exactly, a platform-dependent default is a bad idea.

I concur with Petr and Mark. 

The principal use case for int.to_bytes is to convert an integer of arbitrary 
size to a binary format for storage or transmission.  The corresponding file 
load or received data needs to symmetrically restore the int.  The default 
(whether little or big) needs to be the same on both sides to prevent bugs.  
Otherwise, for portable code, we would have to recommend that people not use 
the default because the output isn't deterministic across systems.

By way of comparison, we've had long standing issues like this in other parts 
of the language.  For example, this gives inconsistent encodings across systems:

    with open(filename) as f:
        f.write(text)

Not long ago, Inada had to sweep through and add encoding="utf-8" to fix all 
the bugs caused by the default platform dependent encoding.   Arguably, most 
code that has ever been written without an explicit encoding is wrong if the 
files were intended to be shared outside the local file system.

So if Veky wants the default to be "big", that's fine by me.  The important 
thing is that a *consistent* default be used (not platform dependent).  I won't 
argue for a "sensible default" because apparently Veky has different 
sensibilities.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue45155>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to