-
Notifications
You must be signed in to change notification settings - Fork 270
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
Adding support for stack.ArrayStack
in C++ backend
#512
Conversation
return NULL; | ||
} | ||
Py_INCREF(&DynamicOneDimensionalArrayType); | ||
PyModule_AddObject(stack, "DynamicOneDimensionalArray", reinterpret_cast<PyObject*>(&DynamicOneDimensionalArrayType)); |
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 segmentation was being thrown because the array types weren't registered in the stack
extension module. So there are two options,
- Register them manually (as I did in the above).
- Import them at runtime via the APIs in https://docs.python.org/3/c-api/import.html.
For now approach in point 1 seems much easier and efficient because we pre-register everything that's going to be used in the module's implementation. So no need to import them during function calls. The second approach is messier as well (PyImport_Import
every now and then whenever we want to use something from another C++ extension module).
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 following code works for me for example with 4b028f1 commit.
from pydatastructs.miscellaneous_data_structures._backend.cpp import _stack
array_stack = _stack.ArrayStack([1, 2, 3], int)
In addition to #512 (comment) I removed calls to |
Great progress @nubol23. I am glad that you are able to figure things out on your own in Python C-API. Let me know if you get stuck somewhere, we will fix the problem. :-) |
Thank you very much @czgdp1807 :) I added the remaining changes for the ArrayStack |
pydatastructs/linear_data_structures/_backend/cpp/arrays/DynamicOneDimensionalArray.hpp
Outdated
Show resolved
Hide resolved
Codecov Report
@@ Coverage Diff @@
## master #512 +/- ##
=============================================
+ Coverage 98.523% 98.528% +0.005%
=============================================
Files 31 32 +1
Lines 3996 4010 +14
=============================================
+ Hits 3937 3951 +14
Misses 59 59
|
stack.ArrayStack
in C++ backend
Great job @nubol23. 🎉🎉 |
Adds cpp backend for the stack implementation.
Based on Issue #511
Work in progress