Re: [C++-sig] Getting object for PyObject (reference counting)

2009-02-27 Thread AFoglia
Murray Cumming wrote: On Fri, 2009-02-27 at 08:34 -0800, Alex Mohr wrote: Murray Cumming wrote: I can't find any definitive documentation that tells me how I should get a boost::python::object to wrap an existing PyObject*. I guess that there's a way to do it that uses an existing reference, an

Re: [C++-sig] Getting object for PyObject (reference counting)

2009-02-27 Thread AFoglia
Murray Cumming wrote: On Fri, 2009-02-27 at 07:35 -0800, Ralf W. Grosse-Kunstleve wrote: The trick is to use boost::python::handle: http://www.boost.org/doc/libs/1_38_0/libs/python/doc/v2/handle.html For example: object python_file((handle<>(borrowed(obj_ptr; Thanks, but like much of th

Re: [C++-sig] create boost array from a Numpy PyArray without copying data?

2009-01-23 Thread AFoglia
Sebastian Walter wrote: And is there a way to get the refcount of an object within Python? I'd like to test if the refcount is correct. sys.getrefcount(obj) Good to know. When I run - --- test.py from _test import * import sys def test_my_array(): a =