Message 320526 - Python tracker (original) (raw)

[Victor]

This method [shuffle()] has a weird API. What is the point of passing a random function, ... I proposed to deprecate this argument and remove it later.

I don't care here. This is a bug report. Making backward-incompatible API changes does nothing to repair existing programs.

... return [population[_min(_int(random() * total), total)] for i in range(k)]

Why not using _randbelow() here? For speed

Yup.

Why not optimizing _randbelow() in this case? Like implementing it in C?

This is a bug report, not an invitation to redesign APIs and complicate implementations in non-trivial ways. If you're keen on that, I suggest opening a different issue and writing the patch.

I'd personally oppose the API change (pointless thrashing), but it's possible the speed benefit of C acceleration of _randbelow() would outweigh the considerable downsides of moving code from Python source to C source.

But none of that is needed to "fix the bug" at hand, if - indeed - people still think it's worth fixing at all. In the years that have passed since this started, I no longer do.