Extending Python the right way...
JB
jblazi at hotmail.com
Fri Dec 13 03:11:19 EST 2002
I'd like to have a Python class
class SL ...
that represents for example a straight line. So it has 3
coordimates, a b and c. But a, b and c mut be multi
precision numbers and I cannot use Python for this. So I
should like to associate to each instance of my Sl class
three C++ objects (multi precision numbers, provided by an
external C++ library. I thought, I could simply right a
Python extension for this, but it is not clear to me, if
this would really be the right solution.
For example having three classes
class POINT #represents point
class SL #straight line
g = SL(1,2,5)
h = SL(3,-1,0)
p = section(g,h)
where p is an instance of the class point. The section would
be computed inside C++, that is the coordinates of the
resulting point would be computed in C++ and they should
again be associated with the instance of the class POINT.
If I use Python floats for the coordinates, things are very
simple as I can stay within Python. (I have alread written
a working prototype.)
But it would be very nice if I could use the multi precision
arithmetic offered by an external C++ library.
Could anybody give me a hint, how to proceed?
TIA,
--
Janos Blazi
More information about the Python-list
mailing list