Vajrasky Kok added the comment:
Raymond, thanks for committing my patch but my name was already put into ACKS
before this commit.
$ grep -R Vajrasky Misc/ACKS
Vajrasky Kok
Vajrasky Kok
--
___
Python tracker rep...@bugs.python.org
Roundup Robot added the comment:
New changeset 463f499ef591 by Raymond Hettinger in branch '3.4':
Issue #19145: Remove duplicate ACKS entry
http://hg.python.org/cpython/rev/463f499ef591
--
___
Python tracker rep...@bugs.python.org
Roundup Robot added the comment:
New changeset 07eb04003839 by Raymond Hettinger in branch '2.7':
Issue #19145: Remove duplicate ACKS entry
http://hg.python.org/cpython/rev/07eb04003839
--
___
Python tracker rep...@bugs.python.org
Larry Hastings added the comment:
The main thing for me isn't that the function and its documentation-pseudocode
are in sync (though in the long run this is desirable). What's important to me
is that the function have a sensible, relevant signature in Python. There was
simply no way to
Raymond Hettinger added the comment:
there's still no way to represent repeat's signature in Python
There is a way using *args and **kwds but that isn't any fun (just like range()
or min() in that regard).
Right now, repeat() does what it is supposed to do. It may currently be
inconvenient
Larry Hastings added the comment:
There is a way using *args and **kwds but that isn't any fun
That's why, earlier, I said a sensible signature. Every function *could* get
the signature (*args, **kwargs) but this imparts no useful semantic
information.
What I would like to see in the
Roundup Robot added the comment:
New changeset dce9dbc8e892 by Raymond Hettinger in branch '3.4':
Issue #19145: Fix handling of negative values for a times keyword argument
to itertools.repeat()
http://hg.python.org/cpython/rev/dce9dbc8e892
--
nosy: +python-dev
Roundup Robot added the comment:
New changeset 85dc4684c83e by Raymond Hettinger in branch '2.7':
Issue #19145: Fix handling of negative values for a times keyword argument
to itertools.repeat()
http://hg.python.org/cpython/rev/85dc4684c83e
--
___
Changes by Raymond Hettinger raymond.hettin...@gmail.com:
--
resolution: - fixed
status: open - closed
versions: +Python 2.7, Python 3.4
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19145
Raymond Hettinger added the comment:
I'm inclined to apply Vajrasky Kok's third version (with minor cleanups).
The rule will be pretty much what Guido stated but without adding a special
case for times=None (that could be an added enhancement at a later time if the
need arose): If I had
Larry Hastings added the comment:
Please clarify, what is my false dilemma?
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19145
___
___
Raymond Hettinger added the comment:
Please clarify
I was referring to your first post, I see two possible choices here ...
[changing the signature to times=-1 or to times=None].
There was another choice, make the code work as originally intended where
omitting the times argument repeats
Changes by Vajrasky Kok sky@speaklikeaking.com:
--
versions: +Python 3.5 -Python 3.4
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19145
___
Vajrasky Kok added the comment:
Here is the ultimate patch for this bug. The doc fix is based on Larry's
writing: https://mail.python.org/pipermail/python-dev/2014-January/132156.html
I made sure the patch could be compiled by Sphinx and displayed nicely. I added
test and comment in the code.
Changes by Mark Lawrence breamore...@yahoo.co.uk:
--
nosy: -BreamoreBoy
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19145
___
___
Larry Hastings added the comment:
For what it's worth: I figured out how this happened. Maybe it's obvious to
you, but this behavior baffled me until I went back and looked at the revision
history.
In revision e260d6daf784, the argument parsing for itertools.repeat looks like
this:
Alexander Belopolsky added the comment:
If equivalent to code is not considered to be part of documentation, then the
meaning of negative times should be documented.
--
nosy: +belopolsky
___
Python tracker rep...@bugs.python.org
Vajrasky Kok added the comment:
How to handle this problem in Python maintenance releases (2.7, 3.3 and
soon-to-be 3.4) is being discussed here:
https://mail.python.org/pipermail/python-dev/2014-January/132101.html
In case, we are taking backporting the full fix road, here is the patch. I
Larry Hastings added the comment:
The logic of the patch is hard to follow. However, it's still examining the
size of args, and now it's examining the size of kwargs, and behaving
differently based on these sizes is exactly what I don't want.
I've attached an example patch of how I would
Mark Lawrence added the comment:
msg209063 from Larry states My concern is that itertools.repeat doesn't parse
its arguments like other Python functions. From my viewpoint the only long
term option is to bring repeat (and other functions that you may have found
exhibiting this behaviour
Larry Hastings added the comment:
I think you've understood it.
The problem is, in order to deprecate the behavior, we first must provide the
new behavior. (That's official policy, in PEP 5.) It's untenable to say
you'll have to stop using 'times=-1' in the future, but you can't use
Mark Lawrence added the comment:
From a user perspective the docs say this itertools.repeat(object[, times]) -
Make an iterator that returns object over and over again. Runs indefinitely
unless the times argument is specified. So to me the use of Times=None in
the equivalent to section is
Vajrasky Kok added the comment:
Larry said, A proper fix for the bug will require changing the semantics of
the function.
It's inappropriate to do that in 2.7, 3.3, and (now that we're in beta) 3.4.
I think we can not have it all and need to be pragmatic in this ticket. While
we can not fix
Larry Hastings added the comment:
Raymond said The preferred behavior is that a negative number always means 0.
My proposal honors that.
We certainly aren't changing this in 3.3 and 2.7, and as release manager for
3.4 I'm pretty sure we aren't changing it there.
--
Vajrasky Kok added the comment:
Serhiy said, Why do you cast PyDict_Size(kwds) to int?
Sorry, Serhiy! Today I just realized there is your review for this ticket. I
couldn't really remember but I think I got conversion warning if I did not
downcast it. Something about I shouldn't not have
Larry Hastings added the comment:
I don't have a patch for this issue. If you're thinking of my nullable ints
patch, that was just an experiment. I'd prefer we figure out what we're going
to do on this issue, and we can talk abut conversion to Argument Clinic later.
--
Vajrasky Kok added the comment:
Here is the updated patch. I try to be conservative here, preserving the
current behaviour.
Negative times is same as zero.
Default value (which can be passed by omitting times) means unlimited.
I did not change the signature repeat(object [,times]) because the
Vajrasky Kok added the comment:
def repeat(object, times=-1): = it could break the code in the wild.
Current behaviour: repeat(object) - unlimited, repeat(object, -1) - 0
repetitions.
--
___
Python tracker rep...@bugs.python.org
Larry Hastings added the comment:
Your patch does not address my concern.
My concern is that itertools.repeat doesn't parse its arguments like other
Python functions. It behaves differently depending on whether times is
passed by position or by keyword. Therefore its actual calling
Vajrasky Kok added the comment:
Larry said, It behaves differently depending on whether times is passed by
position or by keyword.
And that is the bug. It should be the same no matter whether we send times
through positional or keyword. As Raymond has said earlier in this thread, The
Serhiy Storchaka added the comment:
Vajrasky's last patch (v3) in general LGTM. I'm not sure about documentation
changes, sample Python implementation is only a demonstration, it shouldn't be
exact equivalent.
--
___
Python tracker
Larry Hastings added the comment:
This problem been independently rediscovered by people converting
code to Argument Clinic. A Python signature can't express these
semantics, where a parameter behaves differently depending on
whether it's passed in by keyword or by reference. So Argument
Terry J. Reedy added the comment:
Current behaviors 3.4b2
itertools.repeat('a', -1)
repeat('a', 0)
itertools.repeat('a', times=-1)
repeat('a') # forever
itertools.repeat('a', times=-2)
repeat('a', -2)
My opinions (same as what Raymond says -- negative == 0)
The first line is correct in both
Serhiy Storchaka added the comment:
Raymond's patch looks even more cumbersome than previous code. And it doesn't
work in some cases:
it = itertools.cycle([-2, -1])
class Index:
... def __index__(self): return next(it)
...
itertools.repeat(42, times=Index())
repeat(42, -1)
--
Changes by Raymond Hettinger raymond.hettin...@gmail.com:
Added file: http://bugs.python.org/file31972/itertools_repeat.diff
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19145
___
Changes by Ezio Melotti ezio.melo...@gmail.com:
--
nosy: +ezio.melotti, serhiy.storchaka
stage: - patch review
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19145
___
New submission from Vajrasky Kok:
from itertools import repeat
repeat(2, -10).__length_hint__()
0
repeat(2, times=-10).__length_hint__()
18446744073709551606
repeat(2, times=-10)
repeat(2, -10)
repeat(2, -10)
repeat(2, 0)
Hereby, I attached two alternatives of patch to make the behaviour
Vajrasky Kok added the comment:
The second patch makes the negative number parameter/keyword ALWAYS means 0.
--
Added file:
http://bugs.python.org/file31944/fix_itertools_repeat_negative_number_means_0.patch
___
Python tracker rep...@bugs.python.org
Changes by Benjamin Peterson benja...@python.org:
--
assignee: - rhettinger
components: +Extension Modules -Library (Lib)
nosy: +rhettinger
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19145
Raymond Hettinger added the comment:
The preferred behavior is that a negative number always means 0.
That is what lists do:
[1] * (-5)
[]
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19145
Vajrasky Kok added the comment:
Improved the patch which makes negative number *always* means 0. Added comment
and put more test.
--
Added file:
http://bugs.python.org/file31949/fix_itertools_repeat_negative_number_means_0_v2.patch
___
Python
41 matches
Mail list logo