[issue30537] Using PyNumber_AsSsize_t in itertools.islice

2018-01-12 Thread Erik Bray
Erik Bray added the comment: > Users might be better off by not seeing an unhelpful error message when > passing in a numpy.int32, or they might be worse-off by having lost a cue > that they were writing inefficient code (which invisibly creates temporary > integer

[issue30537] Using PyNumber_AsSsize_t in itertools.islice

2018-01-12 Thread Jeroen Demeyer
Jeroen Demeyer added the comment: Just to note that this bug affects SageMath too: https://trac.sagemath.org/ticket/24528 Thanks for fixing! -- nosy: +jdemeyer ___ Python tracker

[issue30537] Using PyNumber_AsSsize_t in itertools.islice

2017-06-08 Thread Raymond Hettinger
Raymond Hettinger added the comment: Applied patch. In theory, this was reasonable. Since islice() deals with indices, checking __index__ seems reasonable. On the other hand, stable high-performance code was changed without any known reasonable use cases, and no one will ever likely see a

[issue30537] Using PyNumber_AsSsize_t in itertools.islice

2017-06-08 Thread Raymond Hettinger
Raymond Hettinger added the comment: New changeset 0ecdc525146ecec9d1549ebf59404c769637a512 by Raymond Hettinger (Will Roberts) in branch 'master': bpo-30537: use PyNumber in itertools.islice instead of PyLong (#1918)

[issue30537] Using PyNumber_AsSsize_t in itertools.islice

2017-06-07 Thread Will Roberts
Will Roberts added the comment: Github PR adds simple test, as well as an entry in Misc/NEWS. -- ___ Python tracker ___

[issue30537] Using PyNumber_AsSsize_t in itertools.islice

2017-06-07 Thread Sven Marnach
Sven Marnach added the comment: The current behaviour of islice() seems inconsistent with the rest of Python. All other functions taking start, stop and step arguments like slice(), range() and itertools.count() do accept integer-like objects. The code given as "roughly equivalent" in the

[issue30537] Using PyNumber_AsSsize_t in itertools.islice

2017-06-05 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: My note was not directly related to your patch. It was a warning about general replacement of PyLong_AsSsize_t with PyNumber_AsSsize_t. There is a code for which this is dangerous. -- ___ Python tracker

[issue30537] Using PyNumber_AsSsize_t in itertools.islice

2017-06-05 Thread Will Roberts
Will Roberts added the comment: Thanks for feedback, Serhiy and Raymond! Github PR now has reverted changes except to the calls in islice_new; I am happy to squash if you would like. Serhiy, this is my first time poking around in CPython code. What are the potential consequences of making

[issue30537] Using PyNumber_AsSsize_t in itertools.islice

2017-06-05 Thread Raymond Hettinger
Raymond Hettinger added the comment: [Michael Seifert] > I'm not sure if there are many use-cases where numpy scalars > make sense as inputs for `islice` Likewise, I'm not sure there is any evidence of a use-case. The incompatible relationship between numpy ints and PyLong_AsSsize_t() has

[issue30537] Using PyNumber_AsSsize_t in itertools.islice

2017-06-03 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Adding support of more general int-like objects in islice() looks reasonable to me. I'm not sure about permutations(), but if make this change, use PyIndex_Check() instead of PyNumber_Check(), or don't use the special check at all, allowing

[issue30537] Using PyNumber_AsSsize_t in itertools.islice

2017-06-02 Thread Roundup Robot
Changes by Roundup Robot : -- pull_requests: +1997 ___ Python tracker ___

[issue30537] Using PyNumber_AsSsize_t in itertools.islice

2017-06-02 Thread Will Roberts
Will Roberts added the comment: Note that this issue also seems to affect other methods in the itertools package, such as permutations. -- nosy: +Will Roberts ___ Python tracker

[issue30537] Using PyNumber_AsSsize_t in itertools.islice

2017-06-01 Thread Mark Dickinson
Changes by Mark Dickinson : -- nosy: +mark.dickinson ___ Python tracker ___ ___

[issue30537] Using PyNumber_AsSsize_t in itertools.islice

2017-06-01 Thread Michael Seifert
New submission from Michael Seifert: In a question on StackOverflow (https://stackoverflow.com/questions/44302946/itertools-does-not-recognize-numpy-ints-as-valid-inputs-on-python-3-6) it was mentioned that numpys scalars cannot be used as index for `itertools.islice`. The reason for this