[issue9213] range purports to implement the Sequence ABC, but is missing index and count methods

2010-09-14 Thread Georg Brandl
Georg Brandl ge...@python.org added the comment: I am -1 on adding new methods to builtins in bugfix releases. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9213 ___

[issue9213] range purports to implement the Sequence ABC, but is missing index and count methods

2010-09-14 Thread Daniel Stutzbach
Daniel Stutzbach dan...@stutzbachenterprises.com added the comment: Sounds reasonable to me. I'll close this and the related 9212 (both fixes are already committed to the py3k branch). -- stage: patch review - committed/rejected status: open - closed

[issue9213] range purports to implement the Sequence ABC, but is missing index and count methods

2010-09-13 Thread Daniel Stutzbach
Daniel Stutzbach dan...@stutzbachenterprises.com added the comment: Committed as r84791. Question: should this bugfix be backported to Python 3.1 and to xrange objects in Python 2.7? Since it's a bugfix that adds new methods, it's a gray-area. (same question applies to the closely related

[issue9213] range purports to implement the Sequence ABC, but is missing index and count methods

2010-09-11 Thread Georg Brandl
Georg Brandl ge...@python.org added the comment: I'd like to have this in 3.2. -- nosy: +georg.brandl priority: high - critical ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9213 ___

[issue9213] range purports to implement the Sequence ABC, but is missing index and count methods

2010-09-11 Thread Daniel Stutzbach
Daniel Stutzbach dan...@stutzbachenterprises.com added the comment: Thanks, Georg, for prodding. As a new committer, I have possibly been erring a little too far on the side of having my patches thoroughly reviewed before committing. I'll commit the patch on Monday if no one raises

[issue9213] range purports to implement the Sequence ABC, but is missing index and count methods

2010-09-10 Thread Daniel Urban
Daniel Urban urban.dani...@gmail.com added the comment: Attached is a greatly revised patch, with two significant changes: - Adds support for !PyLong_CheckExact (using _PySequence_IterSearch) Thanks, indeed, we should support that. Any strong feelings on whether range.index should support

[issue9213] range purports to implement the Sequence ABC, but is missing index and count methods

2010-09-02 Thread Daniel Stutzbach
Daniel Stutzbach dan...@stutzbachenterprises.com added the comment: Thank you for the patch. The patch doesn't handle the case where the object being searched for is !PyLong_CheckExact. For example, the user might pass in a sub-type of int. The existing range_contains supports that case, so

[issue9213] range purports to implement the Sequence ABC, but is missing index and count methods

2010-08-21 Thread Éric Araujo
Éric Araujo mer...@netwok.org added the comment: I can’t comment on C code, but the tests look good to me. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9213 ___

[issue9213] range purports to implement the Sequence ABC, but is missing index and count methods

2010-08-21 Thread Guido van Rossum
Changes by Guido van Rossum gu...@python.org: -- nosy: -gvanrossum ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9213 ___ ___ Python-bugs-list

[issue9213] range purports to implement the Sequence ABC, but is missing index and count methods

2010-08-21 Thread Raymond Hettinger
Raymond Hettinger rhettin...@users.sourceforge.net added the comment: I support adding index() and count() to range objects. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9213 ___

[issue9213] range purports to implement the Sequence ABC, but is missing index and count methods

2010-07-22 Thread Daniel Urban
Daniel Urban urban.dani...@gmail.com added the comment: Sorry, the previous patch has a reference leak. I'm attaching the fixed patch as issue9213a.diff (I also added a few tests with really big ranges). -- Added file: http://bugs.python.org/file18128/issue9213a.diff

[issue9213] range purports to implement the Sequence ABC, but is missing index and count methods

2010-07-21 Thread Daniel Urban
Daniel Urban urban.dani...@gmail.com added the comment: The attached patch adds the range.count and range.index methods. Pseudocode for the two method: def count(self, ob): if ob in self: return 1 else: return 0 def index(self, ob, start=0, stop=len(self)): if ob in

[issue9213] range purports to implement the Sequence ABC, but is missing index and count methods

2010-07-21 Thread Antoine Pitrou
Changes by Antoine Pitrou pit...@free.fr: -- nosy: +gvanrossum, mark.dickinson, rhettinger stage: unit test needed - patch review versions: -Python 2.6, Python 2.7, Python 3.1 ___ Python tracker rep...@bugs.python.org

[issue9213] range purports to implement the Sequence ABC, but is missing index and count methods

2010-07-10 Thread Éric Araujo
Changes by Éric Araujo mer...@netwok.org: -- nosy: +merwok ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9213 ___ ___ Python-bugs-list mailing

[issue9213] range purports to implement the Sequence ABC, but is missing index and count methods

2010-07-10 Thread Raymond Hettinger
Changes by Raymond Hettinger rhettin...@users.sourceforge.net: -- priority: normal - high ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9213 ___

[issue9213] range purports to implement the Sequence ABC, but is missing index and count methods

2010-07-09 Thread Daniel Stutzbach
New submission from Daniel Stutzbach dan...@stutzbachenterprises.com: isinstance(range, collections.Sequence) True [method for method in set(dir(collections.Sequence)) - set(dir(range(1))) if not method.startswith('_')] ['index', 'count'] -- assignee: stutzbach components:

[issue9213] range purports to implement the Sequence ABC, but is missing index and count methods

2010-07-09 Thread Daniel Stutzbach
Daniel Stutzbach dan...@stutzbachenterprises.com added the comment: In Python 2.6 and 2.7, the same problem applies to xrange objects. -- versions: +Python 2.6, Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9213