[issue13201] Implement comparison operators for range objects
Mark Dickinson dicki...@gmail.com added the comment: In most cases, global variables Py_Zero and Py_One would be enough to simplify this kind of code. Agreed. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13201 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13201] Implement comparison operators for range objects
Changes by Mark Dickinson dicki...@gmail.com: -- resolution: - fixed stage: commit review - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13201 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13201] Implement comparison operators for range objects
Roundup Robot devn...@psf.upfronthosting.co.za added the comment: New changeset 479a7dd1ea6a by Mark Dickinson in branch 'default': Issue #13201: equality for range objects is now based on equality of the underlying sequences. Thanks Sven Marnach for the patch. http://hg.python.org/cpython/rev/479a7dd1ea6a -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13201 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13201] Implement comparison operators for range objects
Mark Dickinson dicki...@gmail.com added the comment: I've taken the liberty of updating the patch, with a few minor changes: range_equality - range_equals (like range_contains) move identity check into range_equals move comments before the code they describe (PEP7) add whatsnew entry remove check that range.__hash__ matches object.__hash__ in test_hash change assertEqual into assertIs where appropriate (as suggested by Ezio) additional comments and tests in Lib/test/test_range (ditto) Sven, Ezio: okay to apply this? -- Added file: http://bugs.python.org/file23494/range-compare-v4.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13201 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13201] Implement comparison operators for range objects
Mark Dickinson dicki...@gmail.com added the comment: Hmm. Why does my patch not get a 'review' button? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13201 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13201] Implement comparison operators for range objects
Mark Dickinson dicki...@gmail.com added the comment: Ah, there it is. Never mind. :-) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13201 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13201] Implement comparison operators for range objects
Sven Marnach s...@marnach.net added the comment: Thanks for the updates, Mark. I was just about to look into this again. The changes are fine with me. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13201 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13201] Implement comparison operators for range objects
Sven Marnach s...@marnach.net added the comment: Victor Stinner wrote: If would be nice to have a PyLong_CompareLong() function. In most cases, global variables Py_Zero and Py_One would be enough to simplify this kind of code. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13201 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13201] Implement comparison operators for range objects
Mark Dickinson dicki...@gmail.com added the comment: I get a test failure in test_hash (which is checking exactly that the hash(range) uses the default object hash, so that test is clearly out of date now). Apart from that, the latest patch looks good to me. I'm going to give this a couple of days in case anyone else has any comments, then I'll aim to commit it (with the extra test_hash fix) this weekend. Thanks for all the work on this! -- stage: patch review - commit review ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13201 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13201] Implement comparison operators for range objects
STINNER Victor victor.stin...@haypocalc.com added the comment: +one = PyLong_FromLong(1); +if (!one) +return -1; +cmp_result = PyObject_RichCompareBool(r0-length, one, Py_EQ); +Py_DECREF(one); If would be nice to have a PyLong_CompareLong() function. -- nosy: +haypo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13201 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13201] Implement comparison operators for range objects
Sven Marnach s...@marnach.net added the comment: Mark, thanks again for your comments. (I never looked at the Python source code before, so tey are highly appreciated.) I uploaded a new version of the patch hopefully. -- Added file: http://bugs.python.org/file23441/range-compare-v3.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13201 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13201] Implement comparison operators for range objects
New submission from Sven Marnach s...@marnach.net: It seems some sort of consensus on how to compare range objects has emerged from the python-ideas discussion on comparison of range objects [1]. The attached patch defines '==' and '!=' for range object equality based on the sequence of values they represent. The other comparison operators are left NotImplemented. [1]: http://mail.python.org/pipermail/python-ideas/2011-October/012376.html -- files: range-compare messages: 145705 nosy: smarnach priority: normal severity: normal status: open title: Implement comparison operators for range objects Added file: http://bugs.python.org/file23426/range-compare ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13201 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13201] Implement comparison operators for range objects
Changes by Mark Dickinson dicki...@gmail.com: -- components: +Interpreter Core nosy: +mark.dickinson stage: - patch review type: - feature request versions: +Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13201 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13201] Implement comparison operators for range objects
Mark Dickinson dicki...@gmail.com added the comment: Nice patch! I put some comments on Rietveld. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13201 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13201] Implement comparison operators for range objects
Changes by Ezio Melotti ezio.melo...@gmail.com: -- keywords: +needs review, patch nosy: +ezio.melotti ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13201 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13201] Implement comparison operators for range objects
Changes by Mark Dickinson dicki...@gmail.com: -- assignee: - mark.dickinson ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13201 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13201] Implement comparison operators for range objects
Sven Marnach s...@marnach.net added the comment: Mark, thanks for your comments. Here's a new version of the patch, I answer on Rietveld. -- Added file: http://bugs.python.org/file23429/range-compare-v2.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13201 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13201] Implement comparison operators for range objects
Mark Dickinson dicki...@gmail.com added the comment: The new patch looks fine; I'd still like to have the more explicit reference counting in range_hash (see replies on Rietveld). A few more things: - The patch needs a Misc/NEWS entry before committing; it probably deserves a line in Doc/whatsnew/3.3.rst, too. - The doc update should have a .. versionchanged:: 3.3 note. - Maybe the range_compare function could be renamed to something that makes it clearer it's just doing an equality comparison rather than a generalized comparison. 'range_equality_check'? Or just 'range_equal' or 'range_equality'? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13201 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com