[Pyrex] pyrex for parrots?

Michal Wallace michal at sabren.com
Wed May 25 02:10:47 CEST 2005


On Thu, 19 May 2005, Greg Ewing wrote:

> Michal Wallace wrote:
>
>> Parrot's internal object system is very similar
>> to python's. A PMC (Parrot Magic Cookie - don't
>> ask me why they called it that)
>
> That should be "Parrot Magic Cracker", surely?-)

You would think! :)

>> From my experiments, it seems that PythonObjects
>> work just fine outside of a python interpreter,
>> if you replace the reference counting and interpreter
>> locking functions with stubs,
>
> That sounds very scary and dangerous. Pyrex assumes
> the code it generates is going to run as a module
> imported into a fully functioning Python system, and
> relies on Python's reference counting to deallocate
> temporary objects that it creates.
>
> Even without Pyrex, I wouldn't feel confident that
> complex builtin types such as dictionaries would work
> correctly in a refcount-disabled environment, since
> their implementation may be using other Python
> objects internally.


Why do you say dangerous? I really know nothing about
garbage collection, so I could be completely wrong,
but what's the worst that could happen? A memory leak?
(Parrot has it's own garbage collection scheme)


> In short, to pull this off you'd have to be *very*
> familiar with the internals of Python's implementation,
> whether you use Pyrex or not. Pyrex isn't going to
> provide any easy solutions if you insist on doing
> something as radical as disabling refcounting.

When I asked this, I didn't really understand how
pyrex worked behind the scenes there. Now that I've
actually looked at the code, I have another question. :)

I'm looking through your compiler code, and it looks
a lot like pirate. One thing I've been thinking about
for pirate is to extract the bytecode emitter into its
own module (possibly even a template system), so that 
we could plug in different backends.

It seems like pyrex could benefit from the same kind
of refactoring... Then you could have separate backends 
to create modules for for cpython, jython (using JNI), 
pirate, IronPython, and whatever else crops up. Have 
you thought about doing something like that?

If that sounds at all interesting, I'd like to talk 
about this some more, because I'd be interested in 
working on something like that.


PS, completely off topic:

I used pyrex to wrap apple's CoreMIDI API and talk 
to my keyboard from python. Nothing to show off yet, 
but I also wrote a win32 MIDI module for python 1.5.2 
a long time ago, and the difference between visual c 
and pyrex is like night and day. Thanks for making it! :)

Sincerely,

Michal J Wallace
Sabren Enterprises, Inc.
-------------------------------------
contact: michal at sabren.com
hosting: http://www.cornerhost.com/
my site: http://www.withoutane.com/
-------------------------------------



More information about the Pyrex mailing list