diff options
author | Guido van Rossum <guido@python.org> | 2000-04-10 16:20:31 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2000-04-10 16:20:31 (GMT) |
commit | 44679590e0414cb80c5cc6a95ea4e560b3770247 (patch) | |
tree | 65de58844d7384d56ffb2784c2540c07de17abc1 /Python/compile.c | |
parent | 1a4b593dd67a9c9cbb1560f4c00ac9a63218aca7 (diff) | |
download | cpython-44679590e0414cb80c5cc6a95ea4e560b3770247.zip cpython-44679590e0414cb80c5cc6a95ea4e560b3770247.tar.gz cpython-44679590e0414cb80c5cc6a95ea4e560b3770247.tar.bz2 |
Patch by Vladimir Marangozov to include the function name when
comparing code objects. This give sless surprising results in
-Optimized code. It also sorts code objects by name, now.
[I changed the patch to hash() slightly to touch fewer lines.]
Diffstat (limited to 'Python/compile.c')
-rw-r--r-- | Python/compile.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Python/compile.c b/Python/compile.c index d676b56..97ab99c 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -140,6 +140,8 @@ code_compare(co, cp) PyCodeObject *co, *cp; { int cmp; + cmp = PyObject_Compare(co->co_name, cp->co_name); + if (cmp) return cmp; cmp = co->co_argcount - cp->co_argcount; if (cmp) return cmp; cmp = co->co_nlocals - cp->co_nlocals; @@ -160,7 +162,9 @@ static long code_hash(co) PyCodeObject *co; { - long h, h1, h2, h3, h4; + long h, h0, h1, h2, h3, h4; + h0 = PyObject_Hash(co->co_name); + if (h0 == -1) return -1; h1 = PyObject_Hash(co->co_code); if (h1 == -1) return -1; h2 = PyObject_Hash(co->co_consts); @@ -169,7 +173,7 @@ code_hash(co) if (h3 == -1) return -1; h4 = PyObject_Hash(co->co_varnames); if (h4 == -1) return -1; - h = h1 ^ h2 ^ h3 ^ h4 ^ + h = h0 ^ h1 ^ h2 ^ h3 ^ h4 ^ co->co_argcount ^ co->co_nlocals ^ co->co_flags; if (h == -1) h = -2; return h; |