-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Enhance "wrapping C libraries". #2362
Enhance "wrapping C libraries". #2362
Conversation
…Removed old examples files.
Well, there is the "little" issue that MSVC lacks Also, using |
docs/src/tutorial/clibraries.rst
Outdated
|
||
/* Pop values as long as the predicate evaluates to true for them, | ||
* returns -1 if the predicate failed with an error and 0 otherwise. | ||
*/ | ||
int queue_pop_head_until(Queue *queue, predicate_func predicate, | ||
intptr_t queue_pop_head_until(Queue *queue, predicate_func predicate, |
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.
Sorry, but this is really not what the C-API of the queue looks like.
It's true that it's a lot cleaner now. My experience with plain C is somewhat limited, as you can see. It's getter better with your reviews. |
# method, as the method signature is incompatible with Python argument | ||
# types (Python doesn't have pointers). However, we can make a method | ||
# called `extend_python` instead that accepts an arbitrary Python iterable. | ||
cpdef extend_python(self, values): |
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.
The naming of these two methods was intentional. The Python interface dominates the API of this class and should be consistent. extend()
is the method name a Python user would expect. The additional C-interface should be a second class citizen wherever it cannot match the Python interface.
Maybe we could rename the cdef extend()
method to extend_ints()
. That way, we could easily add an extend_longs()
or extend_chars()
method for convenience, as one would do in C APIs.
…he C libraries tutorial. See #2362.
intptr_t
instead ofint
to avoid warnings of unsafe cast (and crashes since C++ consider casting fromvoid*
toint
an error).examples/tutorial/clibraries
.