|
4 | 4 | */
|
5 | 5 | package org.python.core;
|
6 | 6 |
|
| 7 | +import org.python.expose.ExposedClassMethod; |
| 8 | +import org.python.expose.ExposedMethod; |
| 9 | +import org.python.expose.ExposedNew; |
| 10 | +import org.python.expose.ExposedType; |
| 11 | +import org.python.util.Generic; |
| 12 | + |
7 | 13 | import java.util.Collection;
|
8 | 14 | import java.util.Iterator;
|
9 | 15 | import java.util.Map;
|
10 |
| -import java.util.Set; |
11 | 16 | import java.util.Map.Entry;
|
| 17 | +import java.util.Set; |
12 | 18 | import java.util.concurrent.ConcurrentHashMap;
|
13 | 19 | import java.util.concurrent.ConcurrentMap;
|
14 | 20 |
|
15 |
| -import org.python.expose.ExposedClassMethod; |
16 |
| -import org.python.expose.ExposedMethod; |
17 |
| -import org.python.expose.ExposedNew; |
18 |
| -import org.python.expose.ExposedType; |
19 |
| -import org.python.expose.MethodType; |
20 |
| -import org.python.util.Generic; |
21 |
| - |
22 | 21 | /**
|
23 | 22 | * Special fast dict implementation for __dict__ instances. Allows interned String keys in addition
|
24 | 23 | * to PyObject unlike PyDictionary.
|
@@ -526,13 +525,21 @@ public boolean isSequenceType() {
|
526 | 525 | @Override
|
527 | 526 | public PyObject richCompare(PyObject other, CompareOp op) {
|
528 | 527 | if (op == CompareOp.EQ && other instanceof PyDictionary) {
|
529 |
| - for (PyObject key: ((PyDictionary) other).keys_as_list().asIterable()) { |
530 |
| - if (!get(key).equals(((PyDictionary) other).get(key))) { |
| 528 | + PyDictionary otherDict = (PyDictionary) other; |
| 529 | + if (!keys().__eq__(otherDict.dict_keys()).__bool__()) { |
| 530 | + return Py.False; |
| 531 | + } |
| 532 | + for (PyObject key: otherDict.keys_as_list().asIterable()) { |
| 533 | + if (!get(key).equals(otherDict.get(key))) { |
531 | 534 | return Py.False;
|
532 | 535 | }
|
533 | 536 | }
|
534 | 537 | return Py.True;
|
535 | 538 | }
|
| 539 | + if (op == CompareOp.EQ && other instanceof PyStringMap) { |
| 540 | + PyStringMap otherDict = (PyStringMap) other; |
| 541 | + return otherDict.table.equals(table) ? Py.True : Py.False; |
| 542 | + } |
536 | 543 | return super.richCompare(other, op);
|
537 | 544 | }
|
538 | 545 |
|
|
0 commit comments