-
Notifications
You must be signed in to change notification settings - Fork 75
clean up some unnecessary C-API usages and fix integer sizes #26
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
Conversation
note: integer size fixes which require corresponding changes in itertoolz.pxd
|
Awesome, everything in here looks great. I am a little abashed at writing such dirty code in the first place, so thanks for cleaning it up! I'd like to look at this a little more closely, but I think we can get this merged very soon. By the way, @scoder, I think you've done a fantastic job with |
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.
Additional bindings go in "cytoolz/cpython.pxd".
I would actually like to use different names for the C API functions defined in that file. For example, perhaps function names should use PyPointer_ prefix if the new binding returns a pointer, such as:
cdef extern from "Python.h":
PyObject* PyPointer_GetItem "PyObject_GetItem" (object o, object key)Is this common practice, and what naming conventions make sense?
I'm aware of that, just thought you might want to have some fun cleaning more things up, too. :) Note that there are lots of similar cases in the other modules where writing explicit C-API calls can be avoided. As a rule of thumb, I'd always write things down in Python syntax first, and then look at the C code ("cython -a module.pyx" will give you an HTML view on it, especially nice with the latest Cython master branch and Pygments installed). Only if Cython happens to generate suboptimal code, I'd consider working around that. In many cases, adding a hint like "this isn't None" or an explicit assignment will already help enough.
Something like |
I plan to, and thanks for getting this started :) . I agree with your rules of thumbs (and all of your changes), and I know I didn't look at the annotated output ("cython -a") nearly often enough. A brief history: this project began as a way for me to get my hands dirty with Cython, and I became curious how much
Yeah, we should definitely use different and more descriptive names. There aren't many additional C bindings, so I guess it's too soon to come up with conventions as long as the name of each individual binding makes sense. |
|
Merging. |
clean up some unnecessary C-API usages and fix integer sizes
|
Thanks @scoder ! |
note: integer size fixes which require corresponding changes in itertoolz.pxd