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

Ondrej Certik ondrej at certik.cz
Fri Aug 4 17:53:23 CEST 2006

> Now, please turn this into
>         while(true) { basic *q = pow(e2, e1); }
> and watch you program/computer/any airplane within 20 miles crash. After
> that read about memory leaks.

I was replying to your part of email which says "It will create a new
basic object with only the basic-parts of the power" to show, that it
is possible to do it my way. So, is it the garbage collection which is
the only reason behind ex?

You need to use a garbage collector, if you don't want to delete
instances by yourself.
Like this:

#include <iostream>
#include "gc_cpp.h"

class basic: public gc
//class basic
        basic() {};

you need to inherit basic from "gc". gc_cpp is from

I tested that your while loop

while(true) { basic *q = pow(e2, e1); }

doesn't crash the computer. (it does however if you don't inherit basic from gc)

So back to the original question: is ex only used to do the garbage
collection? The syntax above is imho much less complex than the whole
thing with ex, on the other hand, I understand that if you implement
garbage collection yourself in ex, you have much bigger control of it,
and also (maybe) it is faster.


More information about the GiNaC-list mailing list