-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Release GIL for is_geometry, is_missing and is_valid_input #207
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -165,24 +165,33 @@ static PyUFuncGenericFunction Y_b_funcs[1] = {&Y_b_func}; | |
|
||
/* Define the object -> bool functions (O_b) which do not raise on non-geom objects*/ | ||
static char IsMissing(void* context, PyObject* obj) { | ||
return ((PyObject*)obj == Py_None); | ||
GEOSGeometry* g = NULL; | ||
if (!get_geom((GeometryObject *) obj, &g)) { | ||
return 0; | ||
}; | ||
return g == NULL; | ||
} | ||
static void* is_missing_data[1] = {IsMissing}; | ||
static char IsGeometry(void* context, PyObject* obj) { | ||
return (PyObject_IsInstance(obj, (PyObject*)&GeometryType)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suppose the reason it worked before as well is that IsInstance should work for subclasses? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, indeed, this PyObject_IsInstance recurses through the MRO. |
||
GEOSGeometry* g = NULL; | ||
if (!get_geom((GeometryObject *) obj, &g)) { | ||
return 0; | ||
} | ||
return g != NULL; | ||
} | ||
static void* is_geometry_data[1] = {IsGeometry}; | ||
static char IsValidInput(void* context, PyObject* obj) { | ||
return (IsGeometry(context, obj) | IsMissing(context, obj)); | ||
GEOSGeometry* g = NULL; | ||
return get_geom((GeometryObject *) obj, &g) == 1; | ||
} | ||
static void* is_valid_input_data[1] = {IsValidInput}; | ||
typedef char FuncGEOS_O_b(void* context, PyObject* obj); | ||
static char O_b_dtypes[2] = {NPY_OBJECT, NPY_BOOL}; | ||
static void O_b_func(char** args, npy_intp* dimensions, npy_intp* steps, void* data) { | ||
FuncGEOS_O_b* func = (FuncGEOS_O_b*)data; | ||
GEOS_INIT; | ||
GEOS_INIT_THREADS; | ||
UNARY_LOOP { *(npy_bool*)op1 = func(ctx, *(PyObject**)ip1); } | ||
GEOS_FINISH; | ||
GEOS_FINISH_THREADS; | ||
} | ||
static PyUFuncGenericFunction O_b_funcs[1] = {&O_b_func}; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a comment that
g == NULL
is basically a check for "is None"?