Re: [PyGiNaC-users] Python lists of GiNaC objects?
Status: Alpha
Brought to you by:
jbrandmeyer
From: Richard B. K. <kr...@gi...> - 2005-09-17 21:27:07
|
Hi! On Wed, 14 Sep 2005, Jonathan Brandmeyer wrote: [...] > The ex will be automatically converted back to a numeric when wrapping > it as an object, and list::append() automatically attempts to > wrap/convert any argument it gets in/to a Python object, so just use > result.append( -GiNaC::numeric(x_split.quotient)); Okay, thanks a lot. It works just fine with your suggestions applied. [...] > If you saw manual refcount management in the PyGiNaC code it should be > limited to the custom rvalue converter registration code. In general, > you can just rely on class object's automatic refcount management. Yeah, I came across this stuff in PyGiNaC's file lst.cpp. lst_to_python::convert(const GiNaC::lst&) is where I copied from. > This is because 'l' is actually a Python list, it isn't a GiNaC::exlist > (sp?) pretending to be a Python list. The python list's __str__ method > (invoked by the print statement) annoyingly invokes the __repr__ method > of its containees rather than __str__. Let me try to understand: Is this a feature? > __repr__ isn't defined by > PyGiNaC's classes, so you get the default behavior: the address of the > wrapping PyObject. Why not define it? > There are (at least) two workarounds. [...] Both workarounds appear cumbersome to me. Best wishes -richy. -- Richard B. Kreckel <http://www.ginac.de/~kreckel/> |