Mark Dickinson added the comment:

[Martin]

> I don’t like special values.

Agreed. If we wanted to add this, the obvious API would be to simply make the 
size optional (which would force passing the endianness by name or explicitly 
passing a default value of `None`, but that doesn't seem like a big deal to me).

I'm -0 on the feature itself. On the plus side, the fact that it's not 
completely trivial to compute the size with errors is an argument for including 
that calculation within the Python code. I'd suggest formulas of:

   (x.bit_length() + 7) // 8

for the unsigned case, and

   (~x if x < 0 else x).bit_length() // 8 + 1

for the signed case, these giving the minimal number of bytes necessary for 
encoding x in each case.

----------
nosy: +mark.dickinson

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

Reply via email to