diff -dur .\libs\python\src\object_bak/function.cpp .\libs\python\src\object/function.cpp
old
|
new
|
|
51 | 51 | return this->min_arity(); |
52 | 52 | } |
53 | 53 | |
54 | | extern PyTypeObject function_type; |
| 54 | extern PyTypeObject function_type_skel; |
| 55 | extern PyTypeObject * function_type_ptr; |
55 | 56 | |
56 | 57 | function::function( |
57 | 58 | py_function const& implementation |
… |
… |
|
105 | 106 | } |
106 | 107 | |
107 | 108 | PyObject* p = this; |
108 | | if (Py_TYPE(&function_type) == 0) |
| 109 | if ( function_type_ptr == NULL ) |
109 | 110 | { |
110 | | Py_TYPE(&function_type) = &PyType_Type; |
111 | | ::PyType_Ready(&function_type); |
| 111 | function_type_ptr = PyObject_New( PyTypeObject, &PyType_Type ); |
| 112 | *function_type_ptr = function_type_skel; |
| 113 | ::PyType_Ready(function_type_ptr); |
112 | 114 | } |
113 | 115 | |
114 | 116 | (void)( // warning suppression for GCC |
115 | | PyObject_INIT(p, &function_type) |
| 117 | PyObject_INIT(p, function_type_ptr) |
116 | 118 | ); |
117 | 119 | } |
118 | 120 | |
… |
… |
|
430 | 432 | str const name(name_); |
431 | 433 | PyObject* const ns = name_space.ptr(); |
432 | 434 | |
433 | | if (attribute.ptr()->ob_type == &function_type) |
| 435 | if (attribute.ptr()->ob_type == function_type_ptr) |
434 | 436 | { |
435 | 437 | function* new_func = downcast<function>(attribute.ptr()); |
436 | 438 | PyObject* dict = 0; |
… |
… |
|
453 | 455 | |
454 | 456 | if (existing) |
455 | 457 | { |
456 | | if (existing->ob_type == &function_type) |
| 458 | if (existing->ob_type == function_type_ptr) |
457 | 459 | { |
458 | 460 | new_func->add_overload( |
459 | 461 | handle<function>( |
… |
… |
|
681 | 683 | {NULL, 0, 0, 0, 0} /* Sentinel */ |
682 | 684 | }; |
683 | 685 | |
684 | | PyTypeObject function_type = { |
685 | | PyVarObject_HEAD_INIT(NULL, 0) |
| 686 | PyTypeObject * function_type_ptr = NULL; |
| 687 | PyTypeObject function_type_skel = { |
| 688 | PyVarObject_HEAD_INIT(&PyType_Type, 0) |
686 | 689 | const_cast<char*>("Boost.Python.function"), |
687 | 690 | sizeof(function), |
688 | 691 | 0, |