[GiNaC-list] Python wrapper for a GiNaC derived library

Chris Dams Chris.Dams at mi.infn.it
Thu Aug 3 22:41:13 CEST 2006


Dear Ondrej,

On Thu, 3 Aug 2006, Ondrej Certik wrote:

> series(basic &e, basic&x)

Yes, as long as you are using references you are fine (... well not
really, see below ...). You can call virtual methods through references
and you can cast them back to references to the appropriate child-class of
basic. However, at some point you will need to create real objects. This
is because writing
basic &e = power(a+b, 2)
is not allowed. The compiler will reject it. It would create a reference 
out of a temporary which you cannot do in C++. Oh well, I said that you 
will need to create real objects, so let us write:
basic e = power(a+b, 2)
No! Also not good! It will create a new basic object with only the
basic-parts of the power. Not the base and exponent.

The problem that he compiler rejects references to temporaries is going to
hunt you. The signature of the power constructor cannot be
power::power(basic &b, basic &e) because you cannot pass a+b to the first
(reference!) argument of the constructor. What shall we do then? Leave out 
the &'s. No! this will discard all the add-specific data of a+b and only 
copy the, ehhm well, bare basics.

The point is that your Python data types are already doing for you
automatically what GiNaCs exes are doing in C++: being a reference to a
garbage-collected data type. I don't think it is possible to do without 
that.

> When you created ginac, at around 2001, how much time did you spend
> coding, to achieve the basic functionality? Couple of weeks? Or
> months/years? And how many people - 4?

I didn't spend any time on it when GiNaC was created. I'm a 
second-generation developer. As far as I know, GiNaC was created around 
1998. My first patch went into version 1.0.9 and that was in 2002.

Best wishes,
Chris






More information about the GiNaC-list mailing list