Browse Source

some optimize

blueloveTH 1 year ago
parent
commit
c6473661dd
2 changed files with 8 additions and 11 deletions
  1. 4 11
      include/pocketpy/obj.h
  2. 4 0
      src/codeobject.cpp

+ 4 - 11
include/pocketpy/obj.h

@@ -122,17 +122,6 @@ struct PyObject{
     }
 };
 
-struct PySignalObject: PyObject {
-    PySignalObject() : PyObject(0) {
-        gc_enabled = false;
-    }
-    void _obj_gc_mark() override {}
-};
-
-inline PyObject* const PY_NULL = new PySignalObject();
-inline PyObject* const PY_OP_CALL = new PySignalObject();
-inline PyObject* const PY_OP_YIELD = new PySignalObject();
-
 const int kTpIntIndex = 2;
 const int kTpFloatIndex = 3;
 
@@ -349,4 +338,8 @@ struct Py_<DummyModule> final: PyObject {
     void _obj_gc_mark() override {}
 };
 
+extern PyObject* const PY_NULL;
+extern PyObject* const PY_OP_CALL;
+extern PyObject* const PY_OP_YIELD;
+
 }   // namespace pkpy

+ 4 - 0
src/codeobject.cpp

@@ -23,4 +23,8 @@ namespace pkpy{
         this->argc = -1;
         this->decl = decl;
     }
+
+    PyObject* const PY_NULL = (PyObject*)new int(0);
+    PyObject* const PY_OP_CALL = (PyObject*)new int(1);
+    PyObject* const PY_OP_YIELD = (PyObject*)new int(2);
 }   // namespace pkpy