Stefan Behnel | 1 Jun 14:10 2008
Picon

Re: [Cython] about let users have more control on garbage collection

Hi,

Lisandro Dalcin wrote:
> cdef class Mat: # <- proxy class
>    cdef PetscMat # <- PETSc object, a pointer to a refcounted struct.
> 
> I need to store arbitrary Python objects inside the PETSc object, I'm
> actually storing a dictionary. This dictionary have to survive until
> the PETSc object is deallocated, but that deallocation do not
> necesarily occurs when the instance of my proxy class is deallocated,
> because the PETSc object can still 'live' (that is, a referece being
> owned) inside other PETSc objects.

Can't you work with singleton proxies? That's what we do in lxml. There's
never more than one Python Element proxy for an XML node struct. We use a
factory function to build a proxy for a struct and keep a back pointer from
the struct to the class, so that we can reuse an already existing proxy. All
the Python state is kept in attributes of the proxy object, and the struct can
be freed when the proxy is garbage collected by Python.

Stefan

Fernando Perez | 1 Jun 22:18 2008
Picon

[Cython] Cython tutorial at Scipy 2008?

Hi folks,

I'm in charge of co-organizing (with Travis Oliphant) the tutorial
sessions at Scipy 2008, to be held in August of this year at Caltech:

http://www.scipy.org/SciPy2008
http://www.scipy.org/SciPy2008/Tutorials

Any chance someone from the Cython gang might come and be willing to
give a cython tutorial?  We don't have  too many details sorted out
yet, so we're just feeling things  out...

Cheers,

f
William Stein | 1 Jun 22:23 2008
Picon

Re: [Cython] Cython tutorial at Scipy 2008?

On Sun, Jun 1, 2008 at 1:18 PM, Fernando Perez <fperez.net@...> wrote:
> Hi folks,
>
> I'm in charge of co-organizing (with Travis Oliphant) the tutorial
> sessions at Scipy 2008, to be held in August of this year at Caltech:
>
> http://www.scipy.org/SciPy2008
> http://www.scipy.org/SciPy2008/Tutorials
>
> Any chance someone from the Cython gang might come and be willing to
> give a cython tutorial?  We don't have  too many details sorted out
> yet, so we're just feeling things  out...
>

Robert Bradshaw and I will likely both be in nearby San Diego then,
in which case one or both of us could potentially come.

William
Fernando Perez | 2 Jun 02:46 2008
Picon

Re: [Cython] Cython tutorial at Scipy 2008?

On Sun, Jun 1, 2008 at 1:23 PM, William Stein <wstein@...> wrote:
> On Sun, Jun 1, 2008 at 1:18 PM, Fernando Perez <fperez.net@...> wrote:
>> Hi folks,
>>
>> I'm in charge of co-organizing (with Travis Oliphant) the tutorial
>> sessions at Scipy 2008, to be held in August of this year at Caltech:
>>
>> http://www.scipy.org/SciPy2008
>> http://www.scipy.org/SciPy2008/Tutorials
>>
>> Any chance someone from the Cython gang might come and be willing to
>> give a cython tutorial?  We don't have  too many details sorted out
>> yet, so we're just feeling things  out...
>>
>
> Robert Bradshaw and I will likely both be in nearby San Diego then,
> in which case one or both of us could potentially come.

Great.  I had also listed a Sage tutorial as a potential topic, so as
long as some of you are around, perhaps you could pitch in for that
too?  Right now we're just getting feelers for both who could teach
what, and what people want to see.  It's a bit of a matchmaking game,
but there's no point in offering something if we don't have anyone to
teach it.

Note that in addition to the 2 days of tutorials and 2 days of
conference, the weekend is reserved for dev sprints.  It would be very
nice to have some joint work on sage/cython/numpy/scipy take place.
Many of the usual suspects will be there.

(Continue reading)

William Stein | 2 Jun 03:46 2008
Picon

Re: [Cython] Cython tutorial at Scipy 2008?

On Sun, Jun 1, 2008 at 5:46 PM, Fernando Perez <fperez.net@...> wrote:
> On Sun, Jun 1, 2008 at 1:23 PM, William Stein <wstein@...> wrote:
>> On Sun, Jun 1, 2008 at 1:18 PM, Fernando Perez
<fperez.net@...> wrote:
>>> Hi folks,
>>>
>>> I'm in charge of co-organizing (with Travis Oliphant) the tutorial
>>> sessions at Scipy 2008, to be held in August of this year at Caltech:
>>>
>>> http://www.scipy.org/SciPy2008
>>> http://www.scipy.org/SciPy2008/Tutorials
>>>
>>> Any chance someone from the Cython gang might come and be willing to
>>> give a cython tutorial?  We don't have  too many details sorted out
>>> yet, so we're just feeling things  out...
>>>
>>
>> Robert Bradshaw and I will likely both be in nearby San Diego then,
>> in which case one or both of us could potentially come.
>
> Great.  I had also listed a Sage tutorial as a potential topic, so as
> long as some of you are around, perhaps you could pitch in for that
> too?  Right now we're just getting feelers for both who could teach

I am certainly enthusiastic about doing a Sage tutorial.

> what, and what people want to see.  It's a bit of a matchmaking game,
> but there's no point in offering something if we don't have anyone to
> teach it.
>
(Continue reading)

Fernando Perez | 2 Jun 04:05 2008
Picon

Re: [Cython] Cython tutorial at Scipy 2008?

On Sun, Jun 1, 2008 at 6:46 PM, William Stein <wstein@...> wrote:

> I am certainly enthusiastic about doing a Sage tutorial.

Ok, thanks for the info.  We'll get in touch with you when as soon as
we know a bit more regarding schedule, etc.

Cheers,

f
Ondrej Certik | 2 Jun 13:47 2008
Picon

Re: [Cython] SWIG and Cython

On Fri, May 30, 2008 at 11:43 PM, Lisandro Dalcin <dalcinl@...> wrote:
> Well, In the case of wrapping large, legacy C++ libraries, then the
> choice is not easy, it depend on many factors. I'll try to elaborate
>
> For something like MPI and PETSc in case for mpi4py and petsc4py,
> which are both being converted to Cython, the option is really clear
> for me: just use Cython, do not bother with SWIG.
>
> Why use Cython? Their native API's are just C (well, MPI has a
> standard C++ API, but not much more featured than the C one). Wrapping
> a C API and providing just C-ish functions at the Python level is just
> unpythonic and painfull to use that plain C. You really need a trully
> OO Python API, if not, you Python level API is just much crap than the
> C one, hard to use, perhaps the only you alleviate is error checking.
> Building a OO API targeting Python through using Cython and calling a
> your legacy library C API is just easy, fast, convenient than using
> SWIG and next use the SWIG generated code to implement a
> better-looking, high-level, pythonic API for Python-level consumption.
>
> In the case of a large C++ API its depend on how much of that API it
> makes sense to expose to Python. Let suppose we have an API with a lot
> of classes and a lot of methods (let say 10,20,30 classes, with
> 10,10,30 methods each). Then wrapping the full API in the current
> status of Cython, that is going to be a real pain, to much manual.
> BUT, if you are going to use only a few of your classes, and only
> expose a few of your methods, or even want to expose new methods, more
> convenient to use in the Python side, then, again I will definitelly
> choose Cython.
>
> My personal experience in going from SWIG to Cython is worth to take
(Continue reading)

Lisandro Dalcin | 2 Jun 16:58 2008
Picon

Re: [Cython] about let users have more control on garbage collection

On 6/1/08, Stefan Behnel <stefan_ml@...> wrote:
> Hi,
> Can't you work with singleton proxies? That's what we do in lxml. There's
>  never more than one Python Element proxy for an XML node struct.

I'll take a look, but I believe such approach, even if possible, would
complicate a lot my implementation.

Stefan, iff it is no much work for you, could you point me a link to
the actual lxml code implementing all this machinery?

--

-- 
Lisandro Dalcín
---------------
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
Tel/Fax: +54-(0)342-451.1594
Robert Bradshaw | 2 Jun 20:43 2008

Re: [Cython] SWIG and Cython

On May 30, 2008, at 3:20 PM, Lisandro Dalcin wrote:

> On 5/30/08, rahul garg <whycode@...> wrote:
>> I am a little curious about ctypes. Have you looked at ctypes and  
>> what
>> advantages/disadvantages do you think it has over SWIG and Cython for
>> wrapping the libraries you are interested in? Of course ctypes  
>> doesnt work
>> for C++ but any other specific problems?
>
> Well, a C library API is not just functions and data exported by the
> linker. It is also #define'd macros, typedef'd stuff, custom C structs
> with many slots. If you want to write a full featured wrapper to a
> complex library, the ctypes way is going to be even more painfull than
> SWIG or Cython.
>
> Suppose you want to access, in the MPI case, MPI_COMM_WORLD. Look at
> the header files of major's MPI out there (MPICH2, OpenMPI, HP MPI,
> IBM MPI): in all cases MPI_COMM_WORLD is a #defined thing, in some
> case an integer, in other a pointer. And that applies to all MPI
> predefined handles (operations, datatypes, etc,) and other stuff. You
> just cannot access and manage a full C API in ctypes; at least, I do
> not know how to handle that.
>
> For example, the new Cython-based mpi4py can be build against Python
> version ranging from 2.3 to 3.0 (yes, it is Py3K ready!), and with all
> major MPI's out there, either if they are MPI-1 or MPI-2
> implementation, in Linux, Mac OS X, and Windows. I'll never buy the
> ctypes way until someone can show me that this degree of portability
> is possible. Even if someone can do this with ctypes, I guess such a
(Continue reading)

Robert Bradshaw | 2 Jun 21:22 2008

Re: [Cython] Cython tutorial at Scipy 2008?

On Jun 1, 2008, at 5:46 PM, Fernando Perez wrote:

> On Sun, Jun 1, 2008 at 1:23 PM, William Stein <wstein@...>  
> wrote:
>> On Sun, Jun 1, 2008 at 1:18 PM, Fernando Perez  
>> <fperez.net@...> wrote:
>>> Hi folks,
>>>
>>> I'm in charge of co-organizing (with Travis Oliphant) the tutorial
>>> sessions at Scipy 2008, to be held in August of this year at  
>>> Caltech:
>>>
>>> http://www.scipy.org/SciPy2008
>>> http://www.scipy.org/SciPy2008/Tutorials
>>>
>>> Any chance someone from the Cython gang might come and be willing to
>>> give a cython tutorial?  We don't have  too many details sorted out
>>> yet, so we're just feeling things  out...
>>>
>>
>> Robert Bradshaw and I will likely both be in nearby San Diego then,
>> in which case one or both of us could potentially come.
>
> Great.  I had also listed a Sage tutorial as a potential topic, so as
> long as some of you are around, perhaps you could pitch in for that
> too?  Right now we're just getting feelers for both who could teach
> what, and what people want to see.  It's a bit of a matchmaking game,
> but there's no point in offering something if we don't have anyone to
> teach it.
>
(Continue reading)


Gmane