[Python-ideas] Direct byte<->int conversions (was Re: bitwise operations on bytes)

Antoine Pitrou solipsis at pitrou.net
Mon Aug 10 15:38:36 CEST 2009

Nick Coghlan <ncoghlan at ...> writes:
> int.to_bytes(data, *, size=0, little_endian=None, signed=True)

It would be better IMO if this method belonged to the target type, so that you
can write `bytearray.from_int()` without going through an intermediate bytes

What if `data` is equal to 0? Does it return an empty bytes object? It doesn't
look dangerous to do so, so I'd say go for it.

More information about the Python-ideas mailing list