[issue22434] Use named constants internally in the re module

Serhiy Storchaka report at bugs.python.org
Sun Nov 9 19:45:04 CET 2014


Serhiy Storchaka added the comment:

Thank you Raymond for the review.

> I especially like the removal of superfluous OPCODES dictionary lookups

The disadvantage is that now backporting patches to old branches is harder.

> Since the op codes are singletons, you can use identity tests instead of
> equality checks in sre_parse.py:

This is deliberate. There is small change that the opcodes could became an 
integers in future (after adding introspection to pattern object, or make it 
copyable, or allowing serialization of compiled codes). "is" instead of "==" 
can cause subtle bug. Note that "is" is used during parsing, but getwidth() is 
called from sre_compile.py.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue22434>
_______________________________________


More information about the Python-bugs-list mailing list