Re: [Python-ideas] shuffled

2016-09-06 Thread Arek Bulski
They closed it. Will they accept a patch if I send it? Where is the repo for the code? Never submitted anything to py code base. -- Arkadiusz Bulski -- ___ Python-ideas mailing list [email protected] https://mail.python.org/mailman/listinfo/python

Re: [Python-ideas] shuffled

2016-09-06 Thread Eric V. Smith
On 09/06/2016 05:43 AM, Arek Bulski wrote: > They closed it. Will they accept a patch if I send it? In all likelihood, no. However, if you want to advocate for this change, and try to change their minds, I suggest you read and follow the suggestions that Steven D'Aprano gave you in an earlier emai

Re: [Python-ideas] shuffled

2016-09-06 Thread Steven D'Aprano
On Tue, Sep 06, 2016 at 11:43:54AM +0200, Arek Bulski wrote: > They closed it. Will they accept a patch if I send it? Truth is, probably not. You would need to convince Raymond (and to a lesser extent, Tim) that this is a good idea. See my last email for the *minimum* of what you would need to

Re: [Python-ideas] Shuffled

2016-09-06 Thread Sven R. Kunze
If so, then I would suggest than each list provides a .shuffle method as well (just as sorted/sort does). On 06.09.2016 06:34, Mahmoud Hashemi wrote: I tend to agree with Arek. I've been bitten multiple times, including once yesterday, because shuffle works in place, when I really expect a so

Re: [Python-ideas] PEP 530: Asynchronous Comprehensions

2016-09-06 Thread Sven R. Kunze
On 06.09.2016 03:16, Yury Selivanov wrote: Whereas the following will produce some sort of async lists, sets, and dicts? result = [await fun() async for fun in funcs] result = {await fun() async for fun in funcs} result = {fun: await fun() async for fun in funcs} If so, how do

Re: [Python-ideas] Shuffled

2016-09-06 Thread Arek Bulski
> And if random.shuffle() returned a new list, other people would be bitten because they expected it to be in-place. No one proposes that. shuffled() should be a new function. > One moderately stong piece of evidence would be if this function is widely available in third-party libraries and other

Re: [Python-ideas] Shuffled

2016-09-06 Thread Steven D'Aprano
On Tue, Sep 06, 2016 at 05:29:18PM +0200, Arek Bulski wrote: [I think Arek is quoting me here] > > One moderately stong piece of evidence would be if this function is widely > > available in third-party libraries and other languages. > > Wrong. Python is NOT known for doing everything by how it w

Re: [Python-ideas] PEP 530: Asynchronous Comprehensions

2016-09-06 Thread C Anthony Risinger
On Tue, Sep 6, 2016 at 10:20 AM, Sven R. Kunze wrote: > On 06.09.2016 03:16, Yury Selivanov wrote: > >> >> Whereas the following will produce some sort of async lists, sets, and >>> dicts? >>> >>> result = [await fun() async for fun in funcs] result = {await fun() async for fun in fu

Re: [Python-ideas] PEP 530: Asynchronous Comprehensions

2016-09-06 Thread Nick Coghlan
On 6 September 2016 at 11:22, Yury Selivanov wrote: > On 2016-09-05 3:57 PM, Ivan Levkivskyi wrote: >> There is an old "bug" (some people call this a feature) >> http://bugs.python.org/issue10544 >> If one uses yield in a comprehension, then it leads to unexpected results: > > I'm not sure what wi

Re: [Python-ideas] PEP 530: Asynchronous Comprehensions

2016-09-06 Thread Yury Selivanov
On 2016-09-06 9:40 AM, C Anthony Risinger wrote: On Tue, Sep 6, 2016 at 10:20 AM, Sven R. Kunze > wrote: On 06.09.2016 03:16, Yury Selivanov wrote: Whereas the following will produce some sort of async lists, sets, and dicts?

Re: [Python-ideas] PEP 530: Asynchronous Comprehensions

2016-09-06 Thread Yury Selivanov
On 2016-09-04 3:10 AM, Adam Bartoš wrote: Hello, will await be allowed also in the "if" part of comprehensions? And what about the "in" part? (e.g. if I'm not mistaken, we may have an asynchronous function returning an asynchronous iterator.) Yes, awaits will be allowed. I'll update the P

Re: [Python-ideas] PEP 530: Asynchronous Comprehensions

2016-09-06 Thread Sven R. Kunze
On 06.09.2016 19:38, Yury Selivanov wrote: On 2016-09-06 9:40 AM, C Anthony Risinger wrote: On Tue, Sep 6, 2016 at 10:20 AM, Sven R. Kunze > wrote: So, what's the "async" good for then? Maybe I'm off base here, but my understanding is the `async for` version

Re: [Python-ideas] Shuffled

2016-09-06 Thread Stephen J. Turnbull
Steven D'Aprano writes: > If your only argument is to continue to insist that Python should > have a shuffled() function and you'll write a patch, it will go no > where. First you have to convince people that the patch is needed. It's not worth the effort. The previous attempt (issue26393) to

Re: [Python-ideas] Shuffled

2016-09-06 Thread Sven R. Kunze
Hi Steven, On 06.09.2016 18:32, Steven D'Aprano wrote: On Tue, Sep 06, 2016 at 05:29:18PM +0200, Arek Bulski wrote: [I think Arek is quoting me here] One moderately stong piece of evidence would be if this function is widely available in third-party libraries and other languages. Wrong. Pytho

Re: [Python-ideas] Shuffled

2016-09-06 Thread Chris Angelico
On Wed, Sep 7, 2016 at 4:15 AM, Sven R. Kunze wrote: > It's community project after all. What's that mean, exactly? That the community gets to vote on what goes into Python? Because we don't. ChrisA ___ Python-ideas mailing list [email protected]

Re: [Python-ideas] PEP 530: Asynchronous Comprehensions

2016-09-06 Thread Sven R. Kunze
Hi Srinivas, On 06.09.2016 05:46, srinivas devaki wrote: On Tue, Sep 6, 2016 at 6:46 AM, Yury Selivanov wrote: Hi Sven, I doubt that anybody ever would write something like that; this is just examples of what the PEP will enable. using the same object as iterator and async generator, may be

Re: [Python-ideas] Shuffled

2016-09-06 Thread אלעזר
Naive shuffled() can be emulated using a single expression: sorted(lst, key=lambda _: random()) So there's even less incentive for standardization. ~Elazar ___ Python-ideas mailing list [email protected] https://mail.python.org/mailman/listinf

Re: [Python-ideas] Shuffled

2016-09-06 Thread Sven R. Kunze
Are you serious? The reason for "we don't need standardization" == "there is a solution, long, and with a lot of special characters". Holy c***. I remember Python being the least verbose language on the planet. I suspect this argument didn't lead to status quo. It's like saying, we don't need v

Re: [Python-ideas] PEP 530: Asynchronous Comprehensions

2016-09-06 Thread Nick Coghlan
On 7 September 2016 at 04:24, Sven R. Kunze wrote: > Python async community wants you to write everything twice: for the sync and > async case. And don't dare to mentioned code sharing here. They will rip you > apart. ;) > > Just kidding. Of course would it be great to write code only once but Yur

Re: [Python-ideas] PEP 530: Asynchronous Comprehensions

2016-09-06 Thread Koos Zevenhoven
On Tue, Sep 6, 2016 at 9:24 PM, Sven R. Kunze wrote: [...] > No really, I have absolutely no idea why you need to put that "async" in all > places where Python can detect automatically if it needs to perform an async > iteration or not. Maybe, Yury can explain. I'm sure he would explain, but it s

Re: [Python-ideas] Shuffled

2016-09-06 Thread Tim Peters
[Sven R. Kunze ] > ... > He already convinced some people. Just not some venerable Python devs, which > doesn't necessarily mean something at all. > > Their response: "Oh, I don't need it, let's close it." > Arek: "But I need it." > > So, who's right now? By default, the venerable Python devs ;-)

Re: [Python-ideas] Shuffled

2016-09-06 Thread Bernardo Sulzbach
On 09/06/2016 03:37 PM, Sven R. Kunze wrote: Besides being a silly argument, it's an interesting solution. Does it really work? I remember Microsoft utilizing a similar approach for their browser selection tool which led to a skewed probability distribution. Maybe, I wrong here though. Yes.

Re: [Python-ideas] PEP 530: Asynchronous Comprehensions

2016-09-06 Thread Sven R. Kunze
On 06.09.2016 20:37, Nick Coghlan wrote: On 7 September 2016 at 04:24, Sven R. Kunze wrote: Python async community wants you to write everything twice: for the sync and async case. And don't dare to mentioned code sharing here. They will rip you apart. ;) Just kidding. Of course would it be gr

Re: [Python-ideas] Shuffled

2016-09-06 Thread אלעזר
(Just to be clear, I wasn't trying to suggest this as more than an ad-hoc solution for a throwaway script. But to me, "sorted by random key" is almost as obvious as "shuffled", perhaps more so for non english speakers with little background in CS terms; the words "sorted" and "random" jumps to the

Re: [Python-ideas] Shuffled

2016-09-06 Thread Sven R. Kunze
On 06.09.2016 20:46, Tim Peters wrote: [Sven R. Kunze ] ... He already convinced some people. Just not some venerable Python devs, which doesn't necessarily mean something at all. Their response: "Oh, I don't need it, let's close it." Arek: "But I need it." So, who's right now? By default, th

Re: [Python-ideas] Shuffled

2016-09-06 Thread Sven R. Kunze
On 06.09.2016 20:46, Bernardo Sulzbach wrote: On 09/06/2016 03:37 PM, Sven R. Kunze wrote: Besides being a silly argument, it's an interesting solution. Does it really work? I remember Microsoft utilizing a similar approach for their browser selection tool which led to a skewed probability dis

Re: [Python-ideas] PEP 530: Asynchronous Comprehensions

2016-09-06 Thread Sven R. Kunze
On 06.09.2016 20:45, Koos Zevenhoven wrote: On Tue, Sep 6, 2016 at 9:24 PM, Sven R. Kunze wrote: [...] No really, I have absolutely no idea why you need to put that "async" in all places where Python can detect automatically if it needs to perform an async iteration or not. Maybe, Yury can expl

Re: [Python-ideas] Shuffled

2016-09-06 Thread Tim Peters
[Sven R. Kunze ] >>> >>> ... >>> He already convinced some people. Just not some venerable Python devs, >>> which>> doesn't necessarily mean something at all. >>> >>> Their response: "Oh, I don't need it, let's close it." >>> Arek: "But I need it." >>> >>> So, who's right now? [Tim] >> By default,

Re: [Python-ideas] PEP 530: Asynchronous Comprehensions

2016-09-06 Thread Terry Reedy
On 9/6/2016 2:54 PM, Sven R. Kunze wrote: PS: Nick, I noted that while replying, my mail client made me responding to you and the list as cc. For Thunderbird, this is normal behavior. I suspect you would find the same if your tried 'replay all' to multiple messages. > Is there something wr

Re: [Python-ideas] Shuffled

2016-09-06 Thread David Mertz
On Tue, Sep 6, 2016 at 1:15 PM, Sven R. Kunze wrote: > > Their response: "Oh, I don't need it, let's close it." > Arek: "But I need it." > This definitely feels like a case of "put it on PyPI." Actually, maybe contribute to `boltons`, it feels like it might fit as a utility function there. Whil

Re: [Python-ideas] Shuffled

2016-09-06 Thread Tim Peters
On Tue, Sep 6, 2016 at 2:48 PM, David Mertz wrote: > On Tue, Sep 6, 2016 at 1:15 PM, Sven R. Kunze wrote: >> >> Their response: "Oh, I don't need it, let's close it." >> Arek: "But I need it." > > > This definitely feels like a case of "put it on PyPI." Actually, maybe > contribute to `boltons`,

Re: [Python-ideas] Shuffled

2016-09-06 Thread Tim Peters
[David Mertz ] > This definitely feels like a case of "put it on PyPI." Actually, maybe > contribute to `boltons`, it feels like it might fit as a utility function > there. It's trivial to write such a function if it's truly needed - it would be easier to write it from scratch than to remember wh

Re: [Python-ideas] Shuffled

2016-09-06 Thread Chris Kaynor
On Tue, Sep 6, 2016 at 3:04 PM, Tim Peters wrote: > But would you _use_ it? I'm still asking for use cases. > > When, e.g., I'm randomizing permutations for testing, the last thing I > want is: > > while whatever: > result = function_of_xs(shuffled(xs)) > check result and com

Re: [Python-ideas] PEP 530: Asynchronous Comprehensions

2016-09-06 Thread Guido van Rossum
On Tue, Sep 6, 2016 at 10:42 AM, Yury Selivanov wrote: > On 2016-09-04 3:10 AM, Adam Bartoš wrote: >> will await be allowed also in the "if" part of comprehensions? And what >> about the "in" part? (e.g. if I'm not mistaken, we may have an asynchronous >> function returning an asynchronous iterato

Re: [Python-ideas] Shuffled

2016-09-06 Thread Ethan Furman
On 09/06/2016 11:15 AM, Sven R. Kunze wrote: On 06.09.2016 18:32, Steven D'Aprano wrote: If your only argument is to continue to insist that Python should have a shuffled() function and you'll write a patch, it will go no where. First you have to convince people that the patch is needed. He