[Python-ideas] Add an option for delimiters in bytes.hex()

Alexandre Brault abrault at mapgears.com
Mon May 1 13:49:12 EDT 2017


On 2017-05-01 01:41 PM, Alexandre Brault wrote:
> On 2017-05-01 01:34 PM, Ethan Furman wrote:
>> On 05/01/2017 07:04 AM, Juancarlo Añez wrote:
>>> On Mon, May 1, 2017 at 9:38 AM, Nick Coghlan wrote:
>>>
>>>> just support two
>>>> keyword arguments to hex(): "delimiter" (as you suggest) and
>>>> "chunk_size" (defaulting to 1, so you get per-byte chunking by
>>>> default)
>>> I'd expect "chunk_size"  to mean the number of hex digits (not bytes)
>>> per chunk.
>> I was also surprised by that.  Also, should Python be used on a
>> machine with, say, 24-bit words then a chunk size of three makes more
>> sense that one of 1.5.  ;)
>>
>> -- 
>> ~Ethan~
> A hex digit is 4 bits long. To separate into words, the 24-bit word
> Python would use 3 (counting in bytes as initially proposed), or 6
> (counting in hex digits). Neither option would result in a 1.5
> chunk_size for 24-bit chunks.
>
> Counting chunk_size either in nibbles or bytes seem equally intuitive to
> me (as long as it's documented).
And I only just realised your main concern was about the 12-bit byte of
that 24-bit word architecture. Carry on


More information about the Python-ideas mailing list