This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mark.dickinson
Recipients mark.dickinson, martin.panter, serhiy.storchaka, socketpair
Date 2016-07-28.12:47:31
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1469710051.56.0.215931262176.issue27637@psf.upfronthosting.co.za>
In-reply-to
Content
[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.
History
Date User Action Args
2016-07-28 12:47:31mark.dickinsonsetrecipients: + mark.dickinson, socketpair, martin.panter, serhiy.storchaka
2016-07-28 12:47:31mark.dickinsonsetmessageid: <1469710051.56.0.215931262176.issue27637@psf.upfronthosting.co.za>
2016-07-28 12:47:31mark.dickinsonlinkissue27637 messages
2016-07-28 12:47:31mark.dickinsoncreate