From: Barry S. <ba...@ba...> - 2014-11-09 12:26:10
|
On 14 Oct 2014, at 02:00, π <sun...@gm...> wrote: > Hello PyCXX people, > > I am very glad to find this framework, I have been spending some time digging through the source code attempting to understand how it does its magic. You need a very deep understanding of how C python 2 and C python 3 works internally. The idea behind PyCXX is that you can create modules in C++ with needing to understand all that detail. > > I'm confused by the existence of new-style classes and old-style classes. > > For example, in test_simple.py, both of these are tested? It is a *test* and the tests attempt to provide coverage of all the supported API. Python 3 tests are far better then python 2. > > What are these entities? > > Did someone create a new mechanism for wrapping C++ classes as Python Types that was not backwards compatible (whatever that may mean), and hence both are now coexisting in the CodeBase? CPython has two ways to implement a Class from C. new-style-classes is the replacement for the older API. For new code use the new-style classes gives you more options. > π > > PS looking through the source code, I notice that vast amount of compacting is possible through preprocessor macros and Variadic Templates. I'm in the process of refactoring, mainly so that I can gain some familiarity with the CodeBase and present certain sections in a way that my brain can parse more easily. I've uploaded some of my changes to http://mathpad.wikidot.com/pycxx — the links at the bottom of this page go to various modifications. preprocessor macros are often bad news for the maintenance of code. You can end up with non-obvious bugs that require you to know a lot about the macros to review changes to the code. The uses of templates in PyCXX as a type safe wrapper around a non-template core is for binary code efficiency reasons. The old PyCXX code used templates only and the code size of the resulting binaries for huge. If you have patches that improve the code I will take them, but not if it loses binary code size efficiency or makes the source code fragile. Barry |