classification
Title: Make uuid.UUID use functools.total_ordering
Type: enhancement Stage:
Components: Library (Lib) Versions: Python 3.4
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Ramchandra Apte, brian.curtin, rhettinger, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2013-01-20 03:51 by Ramchandra Apte, last changed 2013-01-22 13:09 by Ramchandra Apte. This issue is now closed.

Files
File name Uploaded Description Edit
issue.patch Ramchandra Apte, 2013-01-20 03:51 review
Messages (11)
msg180275 - (view) Author: Ramchandra Apte (Ramchandra Apte) * Date: 2013-01-20 03:51
This would reduce the complexity of uuid.UUID and also if the way it compares changes, one would't have to change all the compare methods.
Attached is a patch.
msg180277 - (view) Author: Brian Curtin (brian.curtin) * (Python committer) Date: 2013-01-20 05:22
Can you provide test cases for this code?
msg180278 - (view) Author: Ramchandra Apte (Ramchandra Apte) * Date: 2013-01-20 05:22
Yes, will do so.
msg180279 - (view) Author: Ramchandra Apte (Ramchandra Apte) * Date: 2013-01-20 05:24
@Brian Curtin
It appears that there are tests for UUID ordering. [0]
I will run the tests.

[0] http://hg.python.org/cpython/file/d1e6a48dfb0d/Lib/test/test_uuid.py#l188
msg180280 - (view) Author: Ramchandra Apte (Ramchandra Apte) * Date: 2013-01-20 05:34
Damn, I forgot to add import functools.
Here is a fixed version that passes test_uuid.
msg180291 - (view) Author: Ramchandra Apte (Ramchandra Apte) * Date: 2013-01-20 13:54
Oh darn, I included another bugs changes in it.
I unlinked the v2 patch and have attached issue17001-v2.patch
msg180292 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-01-20 13:55
Except for mistakenly included functional.rst changes, the patch looks good for me.
msg180316 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2013-01-20 21:12
I recommend against this patch.  The code generated by functools.total_ordering is less efficient than the existing code and it doesn't handle the NotImplemented logic very well.

total_ordering() is a shortcut, not a best practice.
msg180339 - (view) Author: Ramchandra Apte (Ramchandra Apte) * Date: 2013-01-21 13:23
Performance info using the attached program:
~2.5 sec, original
~3.5 sec, patched
(patched version is 40% slower)
Is anybody doing the comparison in performance-critical cases?
msg180340 - (view) Author: Ramchandra Apte (Ramchandra Apte) * Date: 2013-01-21 13:25
On 21 January 2013 02:42, Raymond Hettinger <report@bugs.python.org> wrote:

> NotImplemented

Can you please elaborate on "it doesn't handle the NotImplemented logic
very well".
AFAIK both will give NotImplemented for the same values.
msg180385 - (view) Author: Ramchandra Apte (Ramchandra Apte) * Date: 2013-01-22 13:09
@Raymond Hettinger
Why? Please respond to my comments.
History
Date User Action Args
2013-01-22 13:09:10Ramchandra Aptesetmessages: + msg180385
2013-01-22 07:13:46rhettingersetstatus: open -> closed
resolution: not a bug
2013-01-21 13:25:48Ramchandra Aptesetmessages: + msg180340
2013-01-21 13:23:51Ramchandra Aptesetmessages: + msg180339
2013-01-20 21:12:24rhettingersetnosy: + rhettinger
messages: + msg180316
2013-01-20 13:55:06serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg180292
2013-01-20 13:54:19Ramchandra Aptesetmessages: + msg180291
2013-01-20 13:51:57Ramchandra Aptesetfiles: - issue-v2.patch
2013-01-20 05:34:17Ramchandra Aptesetfiles: + issue-v2.patch

messages: + msg180280
2013-01-20 05:24:38Ramchandra Aptesetmessages: + msg180279
2013-01-20 05:22:41Ramchandra Aptesetmessages: + msg180278
2013-01-20 05:22:02brian.curtinsetnosy: + brian.curtin
messages: + msg180277
2013-01-20 03:52:47Ramchandra Aptesettype: enhancement
2013-01-20 03:51:39Ramchandra Aptecreate