Re: [Python-ideas] Shuffled

shuffled() should be in the random module, of course. I dont suggest a builtin. Although now that you mentioned it, I could go for that too. There are usage cases where its heavily used, in randomized testing for example. I am sure that there are also other domains where randomization of lists is used. Another reason to put it there is that using shuffle is inconvenient. The fact that I CAN write it myself doesnt mean that it doesnt belong in the standard library. Implementing this in pure python wont take a lot of work. pozdrawiam, Arkadiusz Bulski

On Tue, Sep 06, 2016 at 03:59:10AM +0200, Arek Bulski wrote:
Implementing this in pure python wont take a lot of work.
Great. Well, here's a tracker issue for it. http://bugs.python.org/issue27964 Can you provide a patch? Don't forget the tests and documentation. Providing a patch doesn't mean the patch will be accepted. But no patch means that, even if accepted, you are unlikely to see anything before Python 3.7, as the 3.6 feature freeze is less than a week away. -- Steve

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 sorted()-like behavior for a standalone function like that. Mahmoud https://github.com/mahmoud http://sedimental.org On Mon, Sep 5, 2016 at 6:59 PM, Arek Bulski <arek.bulski@gmail.com> wrote:

On Mon, Sep 05, 2016 at 09:34:05PM -0700, Mahmoud Hashemi wrote:
*shrug* And if random.shuffle() returned a new list, other people would be bitten because they expected it to be in-place. You can't please everyone. In any case, the tracker item I opened has already been closed by the module maintainer Raymond Hettinger. I don't intend to pursue this, but if anyone wishes to change his mind, you will need: - good use-cases for the new function; - evidence that this is common enough to justify; - and (optional, but recommended) an actual patch. If you (generic "you", not Mahmoud or Arek specifically) aren't volunteering to do the work yourself, the barrier to convince somebody else to do it is much higher. One moderately stong piece of evidence would be if this function is widely available in third-party libraries and other languages. That is evidence that this is common enough that people are reinventing the wheel, and therefore we should consider adding a standard wheel. But I don't have the time (or that much interest) to do this, but I encourage others to do their homework if they want to make a strong case for this function. -- Steve

On Tue, Sep 06, 2016 at 03:59:10AM +0200, Arek Bulski wrote:
Implementing this in pure python wont take a lot of work.
Great. Well, here's a tracker issue for it. http://bugs.python.org/issue27964 Can you provide a patch? Don't forget the tests and documentation. Providing a patch doesn't mean the patch will be accepted. But no patch means that, even if accepted, you are unlikely to see anything before Python 3.7, as the 3.6 feature freeze is less than a week away. -- Steve

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 sorted()-like behavior for a standalone function like that. Mahmoud https://github.com/mahmoud http://sedimental.org On Mon, Sep 5, 2016 at 6:59 PM, Arek Bulski <arek.bulski@gmail.com> wrote:

On Mon, Sep 05, 2016 at 09:34:05PM -0700, Mahmoud Hashemi wrote:
*shrug* And if random.shuffle() returned a new list, other people would be bitten because they expected it to be in-place. You can't please everyone. In any case, the tracker item I opened has already been closed by the module maintainer Raymond Hettinger. I don't intend to pursue this, but if anyone wishes to change his mind, you will need: - good use-cases for the new function; - evidence that this is common enough to justify; - and (optional, but recommended) an actual patch. If you (generic "you", not Mahmoud or Arek specifically) aren't volunteering to do the work yourself, the barrier to convince somebody else to do it is much higher. One moderately stong piece of evidence would be if this function is widely available in third-party libraries and other languages. That is evidence that this is common enough that people are reinventing the wheel, and therefore we should consider adding a standard wheel. But I don't have the time (or that much interest) to do this, but I encourage others to do their homework if they want to make a strong case for this function. -- Steve
participants (4)
-
Arek Bulski
-
Mahmoud Hashemi
-
Steven D'Aprano
-
Sven R. Kunze