[PD] Garbage collection / py 0.0.1 python script object

Maurizio Umberto Puxeddu umbpux at tin.it
Sat Mar 30 14:56:16 CET 2002


On Sat, 30 Mar 2002, Larry Troxler wrote:

> jfm3 wrote:
> >
> > I worry a lot about this external, as well as about Joe Sarlo's GrIPD.
>
> And don't forget my scheme extern http:/www.westnet.com/~lt/pd
>
> > Python is not anywhere near a real time language. Run time environments
> > with automatic memory deallocation are very tricky to get to work in
> > bounded time. I worry that when a moderate to large amount of Python
> > code gets loaded, and the program runs for a while, its garbage
> > collection and paging behavior will cause timing failures in even simple
> > MIDI processing. Am I just being up tight about all music code being
> > bounded time, or does anyone else see this as a real issue?
> >
>
> I can't answer for Python, but I assume that any garbage-collecting
> language engine would allow you to disable automatic garbage collection,
> so that it doesn't happen at unexpected times behind your back.

I'm interested in this thread because I embedded a Python interpreter in
Csound few days ago. No release, but I using it. It is documented here:

http://pythonsound.sf.net/pycsound.pdf

I know that Python is not a real-time language. RT is not a must for me
at the moment but obviously people is interested in a possible use of
PyCsound in RT.

The situation of memory management in Python is particular. Here is
how *I* understand the situation. I write so that people can confirm or
deny what I say.

Python has 2 different methods of GC: reference count and cyclic reference
detection. Reference count is performed in a well defined amount of time
and it is the default GC method. It works as far as you don't make cyclic
references. The second GC method has been added to fix this problem and it
periodically scans the list of object, searching for cyclic reference.
When possible it destroy them. This method is optional and can be disabled
and you can check how often it has to be performed. Of course more objects
you have, longer it will take to perform the check (not RT-friendly).
So if you disables the optional GC and write your code so that you make no
reference cycles, you should be able to do long performances.

Maurizio Umberto Puxeddu.




More information about the Pd-list mailing list