-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
46 lines (30 loc) · 763 Bytes
/
Copy pathmain.cpp
File metadata and controls
46 lines (30 loc) · 763 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "Python.h"
#include "mystruct.h"
#include "some_cython_api.h"
#include <stdio.h>
void make_instance_and_call_cython() {
mystruct* instance = new mystruct();
if (assign_data_to_struct(instance) < 0) {
PyErr_PrintEx(errno);
}
if (assign_data_to_struct2(instance) < 0) {
PyErr_PrintEx(errno);
}
//printf("vec new size %lu\n", instance->vec.size());
//printf("vec end value %d\n", instance->vec[instance->vec.size()-1]);
delete instance;
}
int main(int argc, char** argv) {
Py_Initialize();
int r = import_some_cython();
if (r < 0) {
printf("failed to import some cython\n");
PyErr_PrintEx(errno);
return 1;
}
for (int i = 0; i < 10000; i++) {
make_instance_and_call_cython();
}
Py_Finalize();
return 0;
}