Raymond Hettinger added the comment:

Thanks Serhiy.  I really like this clean-up.  When there is an exception in the 
user's root comparison operation, the traceback is more intelligible now.

If you're interested, here are two additional optimizations:

_op_or_eq = '''                                                 
    op_result = self.%s(other)
    # Since bool(NotImplemented) is true, the usual special case test isn't 
needed here
    return op_result or self == other                           
'''

# setting NotImplemented as a local constant saves one or two global lookups 
per call
exec('def %s(self, other, NotImplemented=NotImplemented):%s' % (opname, opfunc 
% root), namespace)

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue23132>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to