Skip to content

Commit 532edcf

Browse files
committed
minor optimization for interpreter in PyDictGetItem to avoid allocation of ThreadState
1 parent a2f9436 commit 532edcf

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyDictGetItem.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,15 @@
6262
public abstract class PyDictGetItem extends Node {
6363
public abstract Object execute(Frame frame, PDict dict, Object item);
6464

65+
// We never need a frame for reading string keys
6566
@Specialization(limit = "3")
67+
static final Object getString(@SuppressWarnings("unused") PDict dict, String item,
68+
@Bind("dict.getDictStorage()") HashingStorage dictStorage,
69+
@CachedLibrary("dictStorage") HashingStorageLibrary lib) {
70+
return lib.getItem(dictStorage, item);
71+
}
72+
73+
@Specialization(replaces = "getString", limit = "3")
6674
static final Object getItemCached(VirtualFrame frame, @SuppressWarnings("unused") PDict dict, Object item,
6775
@Bind("dict.getDictStorage()") HashingStorage dictStorage,
6876
@Cached ConditionProfile frameCondition,

0 commit comments

Comments
 (0)