Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F105758529
external_module.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Mar 19, 13:20
Size
554 B
Mime Type
text/x-c
Expires
Fri, Mar 21, 13:20 (2 d)
Engine
blob
Format
Raw Data
Handle
25035011
Attached To
R7581 SP4E Homework
external_module.cpp
View Options
#include <pybind11/pybind11.h>
namespace py = pybind11;
/* Simple test module/test class to check that the referenced internals data of external pybind11
* modules aren't preserved over a finalize/initialize.
*/
PYBIND11_MODULE(external_module, m) {
class A {
public:
A(int value) : v{value} {};
int v;
};
py::class_<A>(m, "A")
.def(py::init<int>())
.def_readwrite("value", &A::v);
m.def("internals_at", []() {
return reinterpret_cast<uintptr_t>(&py::detail::get_internals());
});
}
Event Timeline
Log In to Comment