http://cython.org/talks/SageX.pdf

John Arbash Meinel john at arbash-meinel.com
Wed Sep 17 16:50:22 BST 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Robert Collins wrote:
> http://cython.org/talks/SageX.pdf
> 
> This is the best reference I've found to date about the internal
> differences in cython, which was referenced during the recent startup
> thread.
> 
> It *looks* very interesting, but:
>  - not packaged in Ubuntu AFAICT
>  - not sure about availability elsewhere
> 
> I'll probably try manually making it work shortly, but I'd like John and
> others that have worked on C extensions and the related profiling to
> chime in with whether they thing this is likely a big enough win to
> pursue even with its likely harsh dependency chain in the short term.
> 
> -Rob
> 

So, I'd like to go over what we would actually *get* from switching to
Cython. The items I see (page 17):

1) List comprehension. Would be nice as it makes it easier to take the
python-code-we-already-have. Though it isn't hard to turn it into:
  for ...
     PyList_Append

2) 'inline', I'm not sure how necessary this is, but it could be nice.

3) "in-place" arithmetic I think is "+=", but that is already in newer
versions of Pyrex

4) page 34, runtime checks to see if you can use raw offsets instead of
__getitem__ indexing.

This is a bigger item, as it would save some of the manual hackery I've
done with "PyTuple_GetItem".

5) page 36, "len, hash, isinstance" have builtin equivalents. Seems to
already be in Pyrex. (I see len(foo) get translated into PyObject_Length
instead of looking up 'len' by name.) However, this again requires a
newer Pyrex. (I think it is in 0.9.8 rather than 0.9.6.) I know I
recently upgraded my pyrex on Windows, and I had to delete and re-create
the .c file to get the updated 'len()' calls.


So, I would guess cython is "better" than pyrex. At a minimum it seems
to have multiple developers, while Pyrex is a one-man integrator who
wants to understand all changes (have deep knowledge of the full
codebase). There is good in that, but it generally means it evolves more
slowly. Also, nested imports in Pyrex are a bit clumsy. (you are
supposed to name your C file foo.bar.pyx rather than foo/bar.pyx.)

I can't say that it is enough to overcome not being available by default.

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkjRJz4ACgkQJdeBCYSNAAOBHwCgzABRRD53Xo3vGLTrs3NjJkOU
hlEAoJ1LBeJ2F3APaREywMinu07nbh2a
=+dtK
-----END PGP SIGNATURE-----



More information about the bazaar mailing list