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

Erik python at lucidity.plus.com
Wed May 3 19:13:25 EDT 2017


Hi Paul,

On 03/05/17 08:57, Paul Moore wrote:
 > On 3 May 2017 at 02:48, Erik <python at lucidity.plus.com> wrote:
 >> Anyway, I know you can't stop anyone from *proposing* something like 
this,
 >> but as soon as they do you may decide to quote the recipe from
 >> "https://docs.python.org/3/library/functions.html#zip" and try to block
 >> their proposition. There are already threads on fora that do that.
 >>
 >> That was my sticking point at the time when I implemented a general
 >> solution. Why bother to propose something that (although it made my code
 >> significantly faster) had already been blocked as being something that
 >> should be a python-level operation and not something to be included in a
 >> built-in?
 >
 > It sounds like you have a reasonable response to the suggestion of
 > using zip- that you have a use case where performance matters, and
 > your proposed solution is of value in that case.

I don't think so, though.

I had a use-case where splitting an iterable into a sequence of 
same-sized chunks efficiently improved the performance of my code 
significantly (processing a LOT of 24-bit, multi-channel - 16 to 32 - 
PCM streams from a WAV file).

Having thought "I need to split this stream by a fixed number of bytes" 
and then found more_itertools.chunked() (and the 
zip_longest(*([iter(foo)] * num)) trick) it turned out they were not 
quick enough so I implemented itertools.chunked() in C.

That worked well for me, so when I was done I did a search in case it 
was worth proposing as an enhancement to feed it back to the community. 
Then I came across things such as the following:

http://bugs.python.org/issue6021

I am specifically referring to the "It has been rejected before" 
comment, also mentioned here:

https://mail.python.org/pipermail/python-dev/2012-July/120885.html

See this entire thread, too:

https://mail.python.org/pipermail/python-ideas/2012-July/015671.html

This is the reason why I really just didn't care enough to go through 
the process of proposing it in the end (even though the 
more_itertools.chunked function was one of the first 3 implemented in 
V1.0 and seems to _still_ be cropping up all the time in different 
guises - so is perhaps more fundamental than people recognise).

The strong implication of the discussions linked to above is that if it 
had been mentioned before it would be immediately rejected, and that was 
supported by several members of the community in good standing.

So I didn't propose it. I have no idea now what I spent my saved hours 
doing, but I imagine that it was fun

 > Whether it's a
 > *sufficient* response remains to be seen, but unless you present the
 > argument we won't know.

Summary: I didn't present the argument because I'm not a masochist

Regards, E.



More information about the Python-ideas mailing list