Author: Ronan Lamy <[email protected]>
Branch: 
Changeset: r92529:d4810ff5fe4b
Date: 2017-10-01 16:23 +0200
http://bitbucket.org/pypy/pypy/changeset/d4810ff5fe4b/

Log:    Move get_slot_tp_function from slotdefs to typeobject

diff --git a/pypy/module/cpyext/slotdefs.py b/pypy/module/cpyext/slotdefs.py
--- a/pypy/module/cpyext/slotdefs.py
+++ b/pypy/module/cpyext/slotdefs.py
@@ -429,23 +429,6 @@
 
 from rpython.rlib.nonconst import NonConstant
 
-SLOTS = {}
-
[email protected]()
-def get_slot_tp_function(space, typedef, name):
-    """Return a description of the slot C function to use for the built-in
-    type for 'typedef'.  The 'name' is the slot name.  This is a memo
-    function that, after translation, returns one of a built-in finite set.
-    """
-    key = (typedef, name)
-    try:
-        return SLOTS[key]
-    except KeyError:
-        slot_func = build_slot_tp_function(space, typedef, name)
-        api_func = slot_func.api_func if slot_func else None
-        SLOTS[key] = api_func
-        return api_func
-
 def build_slot_tp_function(space, typedef, name):
     w_type = space.gettypeobject(typedef)
 
diff --git a/pypy/module/cpyext/typeobject.py b/pypy/module/cpyext/typeobject.py
--- a/pypy/module/cpyext/typeobject.py
+++ b/pypy/module/cpyext/typeobject.py
@@ -31,7 +31,7 @@
     PyObject, make_ref, from_ref, get_typedescr, make_typedescr,
     track_reference, Py_DecRef, as_pyobj)
 from pypy.module.cpyext.slotdefs import (
-    slotdefs_for_tp_slots, slotdefs_for_wrappers, get_slot_tp_function,
+    slotdefs_for_tp_slots, slotdefs_for_wrappers, build_slot_tp_function,
     llslot)
 from pypy.module.cpyext.state import State
 from pypy.module.cpyext.structmember import PyMember_GetOne, PyMember_SetOne
@@ -226,6 +226,22 @@
             dict_w[name] = w_descr
             i += 1
 
+SLOTS = {}
[email protected]()
+def get_slot_tp_function(space, typedef, name):
+    """Return a description of the slot C function to use for the built-in
+    type for 'typedef'.  The 'name' is the slot name.  This is a memo
+    function that, after translation, returns one of a built-in finite set.
+    """
+    key = (typedef, name)
+    try:
+        return SLOTS[key]
+    except KeyError:
+        slot_func = build_slot_tp_function(space, typedef, name)
+        api_func = slot_func.api_func if slot_func else None
+        SLOTS[key] = api_func
+        return api_func
+
 missing_slots={}
 def update_all_slots(space, w_type, pto):
     # fill slots in pto
@@ -248,8 +264,6 @@
             # if it happens to come from some parent class
             slot_apifunc = get_slot_tp_function(space, typedef, slot_name)
         else:
-            # For heaptypes, w_type.layout.typedef will be object's typedef, 
and
-            # get_slot_tp_function will fail
             w_descr = search_dict_w.get(method_name, None)
             if w_descr:
                 # use the slot_apifunc (userslots) to lookup at runtime
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to