[GNC-dev] Python: About Wrapping SWIG Objects (GncNumeric)

Geert Janssens geert.gnucash at kobaltwit.be
Mon Aug 6 05:35:30 EDT 2018

Op maandag 6 augustus 2018 05:32:27 CEST schreef John Ralls:
> > On Aug 5, 2018, at 5:17 PM, c.holtermann at gmx.de wrote:
> > 
> > Hello,
> > 
> > after some time I get back to the gnucash python bindings.
> > 
> > I worked on a str method for GncNumeric. It's in the example_script
> > dir
> > (https://github.com/Gnucash/gnucash/blob/maint/bindings/python/example_sc
> > ripts/str_methods.py) I changed it to python3.

I read at the beginning of this file you chose to implement it as an example 
script which - if found useful - could be added to gnucash_core.

You have my blessing to include it in gnucash_core :)

> > Well I found it interesting to think these things through. Maybe someone
> > can tell me about the mysterious "later on" in the cited comment. At this
> > point I find it useful to have a way from the instance to the wrapping
> > object through some kind of link as I suggested in the patch to
> > function_class.
> Christoph,
> The person who wrote the first two lines of that, Mark Jenkins, was the
> original source of the Python bindings. He was never a regular dev, he just
> got 16 patches committed between 2007 and 2012, 10 of which touched the
> python bindings. Your history with them is almost as long as his--in fact
> you have *12* commits--and pretty much no one else has done anything
> serious with them.
Hopefully Mark is still around on the list to clarify.

> In other words, if anyone knows, it’s you!

True :)

> Just to add some more confusion, there’s now a C++ class GncNumeric that
> handles the actual implementation of many of the gnc_numeric.* functions. I
> believe that SWIG can’t see it, only the C wrapper functions are exposed to
It would be a very useful experiment to wrap the C++ GncNumeric class directly 
rather than it's c wrapper gnc_numeric_xxx. Python doesn't need the c 
compatibility layer it represents.


More information about the gnucash-devel mailing list