[Python-Dev] Negative times behaviour in itertools.repeat for Python maintenance releases (2.7, 3.3 and maybe 3.4)
Larry Hastings
larry at hastings.org
Mon Jan 27 14:13:01 CET 2014
On 01/27/2014 04:56 AM, Steven D'Aprano wrote (rearranged slightly so I
could make my points in order):
> I'm confused... you seem to be saying that you are *against* changing
> the behaviour of repeat so that:
>
> repeat(x, -1)
>
> and
>
> repeat(x, times=-1)
>
> behave the same. Is that actually what you mean, or have I
> misunderstood?
I apologize for not making myself clear. But that's part of what I
meant, yes: we should preserve the existing behavior of times=-1 when
passed in by position or by keyword. However, we should *also* add a
deprecation warning when passing times=-1 by keyword, suggesting that
they use times=None instead. The idea is that we could eventually
remove the PyTuple_Size check and make times=-1 always behave like
times=0. In practice it'd be okay with me if we never did, or at least
not until Python 4.
> Are you rejecting the idea that the current behaviour is an out and out
> buggy, and therefore fixing these things can and should occur in a
> bug-fix release?
While it's a bug, it's a very minor bug. As Python 3.4 release manager,
my position is: Python 3.4 is in beta, so let's not change semantics for
purity's sakes now. I'm -0.5 on adding times=None right now, and until
we do we can't deprecate the old behavior.
> Are there any other functions in the standard library where the
> behaviour differs depending on whether an argument is given positionally
> or by keyword?
Not that I know of. This instance seems to be purely unintentional; see
my latest message on the relevant issue, where I went back and figured
out why itertools.repeat behaves like this in the first place:
http://bugs.python.org/issue19145#msg209440
Cheers,
//arry/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20140127/5bf105d9/attachment.html>
More information about the Python-Dev
mailing list