Commit 9a02e1ca authored by Boxiang Sun's avatar Boxiang Sun

Add Pyston support

Pyston is another Python implementation. More like CPython + JIT. Patch
Cython to add Pyston support.
parent ffa9234c
...@@ -553,7 +553,7 @@ PyObject *__Pyx_Coroutine_SendEx(__pyx_CoroutineObject *self, PyObject *value) { ...@@ -553,7 +553,7 @@ PyObject *__Pyx_Coroutine_SendEx(__pyx_CoroutineObject *self, PyObject *value) {
__Pyx_PyThreadState_assign __Pyx_PyThreadState_assign
if (value) { if (value) {
#if CYTHON_COMPILING_IN_PYPY #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_PYSTON
// FIXME: what to do in PyPy? // FIXME: what to do in PyPy?
#else #else
// Generators always return to their most recent caller, not // Generators always return to their most recent caller, not
...@@ -580,7 +580,7 @@ PyObject *__Pyx_Coroutine_SendEx(__pyx_CoroutineObject *self, PyObject *value) { ...@@ -580,7 +580,7 @@ PyObject *__Pyx_Coroutine_SendEx(__pyx_CoroutineObject *self, PyObject *value) {
if (retval) { if (retval) {
__Pyx_ExceptionSwap(&self->exc_type, &self->exc_value, __Pyx_ExceptionSwap(&self->exc_type, &self->exc_value,
&self->exc_traceback); &self->exc_traceback);
#if CYTHON_COMPILING_IN_PYPY #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_PYSTON
// FIXME: what to do in PyPy? // FIXME: what to do in PyPy?
#else #else
// Don't keep the reference to f_back any longer than necessary. It // Don't keep the reference to f_back any longer than necessary. It
...@@ -1486,7 +1486,7 @@ static void __Pyx__ReturnWithStopIteration(PyObject* value); /*proto*/ ...@@ -1486,7 +1486,7 @@ static void __Pyx__ReturnWithStopIteration(PyObject* value); /*proto*/
static void __Pyx__ReturnWithStopIteration(PyObject* value) { static void __Pyx__ReturnWithStopIteration(PyObject* value) {
PyObject *exc, *args; PyObject *exc, *args;
#if CYTHON_COMPILING_IN_CPYTHON #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_PYSTON
__Pyx_PyThreadState_declare __Pyx_PyThreadState_declare
if ((PY_VERSION_HEX >= 0x03030000 && PY_VERSION_HEX < 0x030500B1) || unlikely(PyTuple_Check(value))) { if ((PY_VERSION_HEX >= 0x03030000 && PY_VERSION_HEX < 0x030500B1) || unlikely(PyTuple_Check(value))) {
args = PyTuple_New(1); args = PyTuple_New(1);
......
...@@ -1200,6 +1200,10 @@ static PyObject* __Pyx_Method_ClassMethod(PyObject *method) { ...@@ -1200,6 +1200,10 @@ static PyObject* __Pyx_Method_ClassMethod(PyObject *method) {
// cdef classes // cdef classes
return PyClassMethod_New(method); return PyClassMethod_New(method);
} }
#else
#if CYTHON_COMPILING_IN_PYSTON
// Pyston add this API for convinience.
if (PyMethodDescr_Check(method)) {
#else #else
// It appears that PyMethodDescr_Type is not anywhere exposed in the Python/C API // It appears that PyMethodDescr_Type is not anywhere exposed in the Python/C API
static PyTypeObject *methoddescr_type = NULL; static PyTypeObject *methoddescr_type = NULL;
...@@ -1210,6 +1214,7 @@ static PyObject* __Pyx_Method_ClassMethod(PyObject *method) { ...@@ -1210,6 +1214,7 @@ static PyObject* __Pyx_Method_ClassMethod(PyObject *method) {
Py_DECREF(meth); Py_DECREF(meth);
} }
if (PyObject_TypeCheck(method, methoddescr_type)) { if (PyObject_TypeCheck(method, methoddescr_type)) {
#endif
// cdef classes // cdef classes
PyMethodDescrObject *descr = (PyMethodDescrObject *)method; PyMethodDescrObject *descr = (PyMethodDescrObject *)method;
#if PY_VERSION_HEX < 0x03020000 #if PY_VERSION_HEX < 0x03020000
......
...@@ -53,6 +53,33 @@ ...@@ -53,6 +53,33 @@
#define CYTHON_UNPACK_METHODS 0 #define CYTHON_UNPACK_METHODS 0
#undef CYTHON_FAST_THREAD_STATE #undef CYTHON_FAST_THREAD_STATE
#define CYTHON_FAST_THREAD_STATE 0 #define CYTHON_FAST_THREAD_STATE 0
#elif defined(PYSTON_VERSION)
#define CYTHON_COMPILING_IN_PYSTON 1
#define CYTHON_COMPILING_IN_PYPY 0
#define CYTHON_COMPILING_IN_CPYTHON 0
#ifndef CYTHON_USE_TYPE_SLOTS
#define CYTHON_USE_TYPE_SLOTS 1
#endif
#undef CYTHON_USE_ASYNC_SLOTS
#define CYTHON_USE_ASYNC_SLOTS 0
#undef CYTHON_USE_PYLIST_INTERNALS
#define CYTHON_USE_PYLIST_INTERNALS 0
#ifndef CYTHON_USE_UNICODE_INTERNALS
#define CYTHON_USE_UNICODE_INTERNALS 1
#endif
#undef CYTHON_USE_PYLONG_INTERNALS
#define CYTHON_USE_PYLONG_INTERNALS 0
#ifndef CYTHON_AVOID_BORROWED_REFS
#define CYTHON_AVOID_BORROWED_REFS 0
#endif
#ifndef CYTHON_ASSUME_SAFE_MACROS
#define CYTHON_ASSUME_SAFE_MACROS 1
#endif
#ifndef CYTHON_UNPACK_METHODS
#define CYTHON_UNPACK_METHODS 1
#endif
#undef CYTHON_FAST_THREAD_STATE
#define CYTHON_FAST_THREAD_STATE 0
#else #else
#define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_PYPY 0
#define CYTHON_COMPILING_IN_CPYTHON 1 #define CYTHON_COMPILING_IN_CPYTHON 1
...@@ -186,8 +213,14 @@ ...@@ -186,8 +213,14 @@
#define PyObject_Realloc(p) PyMem_Realloc(p) #define PyObject_Realloc(p) PyMem_Realloc(p)
#endif #endif
#define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0) /* Pyston provided out off box */
#define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno) #if !CYTHON_COMPILING_IN_PYSTON
#define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
#define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno)
#else
#define __Pyx_PyCode_HasFreeVars PyCode_HasFreeVars
#define __Pyx_PyFrame_SetLineNumber PyFrame_SetLineNumber
#endif
#define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b)) #define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
#define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b)) #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
// but maybe some other profilers don't. // but maybe some other profilers don't.
#ifndef CYTHON_PROFILE #ifndef CYTHON_PROFILE
#if CYTHON_COMPILING_IN_PYPY #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_PYSTON
#define CYTHON_PROFILE 0 #define CYTHON_PROFILE 0
#else #else
#define CYTHON_PROFILE 1 #define CYTHON_PROFILE 1
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment