-
Notifications
You must be signed in to change notification settings - Fork 2.2k
[DEMO] Add .get_capsule_for_scipy_LowLevelCallable()
method in function_record_pyobject.h
#5585
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
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…ch")` macos-13 • brew install llvm ``` /Users/runner/work/pybind11/pybind11/include/pybind11/detail/function_record_pyobject.h:40:26: error: cast from 'PyObject *(*)(PyObject *, PyObject *, PyObject *)' (aka '_object *(*)(_object *, _object *, _object *)') to 'PyCFunction' (aka '_object *(*)(_object *, _object *)') converts to incompatible function type [-Werror,-Wcast-function-type-mismatch] 40 | = {{"__reduce_ex__", (PyCFunction) reduce_ex_impl, METH_VARARGS | METH_KEYWORDS, nullptr}, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ ```
This reverts commit 0da8312.
``` /__w/pybind11/pybind11/include/pybind11/detail/function_record_pyobject.h:215:10: error: implicit conversion 'int' -> 'bool' [readability-implicit-bool-conversion,-warnings-as-errors] 215 | if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s", const_cast<char **>(kwlist), &signature)) { | ~^ | == 0 /__w/pybind11/pybind11/include/pybind11/detail/function_record_pyobject.h:230:5: error: 'auto cap' can be declared as 'auto *cap' [readability-qualified-auto,-warnings-as-errors] 230 | auto cap = reinterpret_cast<capture *>(&rec->data); | ^~~~ | auto * ```
…ethod' object has no attribute '__self__'
…he function pointer. Also make the function a bit more unique (square → square21) for easier pin-pointing. Related ChatGPT conversation regarding `extern "C"`: https://chatgpt.com/share/67e6481e-0994-8008-a64a-a07ce2b781ea
…_LowLevelCallable_NO_TYPE_SAFETY. Make the reinterpret_cast from function pointer to void pointer explicit for clarity.
…d11/functional.h, pybind11/detail/function_record_pyobject.h Also `static_assert(std::is_standard_layout<capture>::value, "")` in all three places. ChatGPT conversation guiding gh-rwgk through the subtle changes: https://chatgpt.com/share/67e66f74-cc80-8008-8b19-1d02e86acf71
…_capsule_for_scipy_LowLevelCallable_NO_ABI_OR_TYPE_SAFETY`)
…PTIMIZATIONS macro, for readability/maintainability.
…D11_DETAIL_FUNCTION_RECORD_ABI_ID, PYBIND11_INTERNALS_ID
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This was an experiment/demo:
This works for any pybind11-wrapped function that is "stateless", but ABI safety and type safety are missing completely.
Slightly safer alternatives are easy to implement. See e.g.
Suggested changelog entry: