[Pyrex] Pyrex idioms and optimizations?

William Stein wstein at gmail.com
Tue Jul 24 20:59:48 CEST 2007


On 7/24/07, Stefan Behnel <stefan_ml at behnel.de> wrote:
> > todo list for a long time.  Great work.  Where do we download this from
> > again?
>
> The SVN repository is here:
>
> Pyrex:
> http://codespeak.net/svn/lxml/pyrex/
>
> Current lxml:
> http://codespeak.net/svn/lxml/trunk/
>
> A checkout of lxml (or the source .tgz) will also get you Pyrex, BTW.

Thanks.  We'll attempt to merge everything and see what happens.

> > Yes.
> >
> >> I just grep-ed for "Py_ssize_t" in the official 0.9.5.1a sources and
> >> didn't
> >> find anything. There were a lot of API changes that require the
> >> Py_ssize_t
> >> type, so I can't imagine it works without having Py_ssize_t in the
> >> generator
> >> somewhere.
> >
> > That's depressing.   I guess what really happened is that Greg told me he
> > would include it, but maybe he didn't.  In SageX Py_ssize_t is definitely
> > fully supported on 64-bit.
>
> Did you write the SageX patches yourself? (just to make sure we are not just
> talking about my own patches that I sent to the Pyrex list more than a year ago).


My memory is hazy about this, but I wrote some of them because I
desperately wanted to have SAGE work with Python 2.5 as soon as
possible, since Python 2.5 had some many verty important improvements
over 2.4 (from the point of view of SAGE).

> http://comments.gmane.org/gmane.comp.python.pyrex/1767
>
> I think I also read somewhere that SageX did something about function
> signatures of C-implemented Python functions. Does it have a way to make them
> visible for tools like epydoc? I've been looking for something like that for a
> while now.

Maybe.  If by "c-implemented" you mean something like

cdef foo(a,b,c):
    ...

then no, sagex doesn't do anything yet.   What sagex does
currently do is that if you give a certain command line
option when running sagex, it will embed the exact location
in the .pyx file where the function is defined in the docstring.
Then (our slightly modified) IPython and Sage allowed one to
do source code introspection on Python-accessible functions
defined in .pyx files.  E.g., in SAGE

sage: n = 5   # SAGE gmp based integer
sage: n.isqrt??                       #  <--- Get to see the *source code*.
Type:           builtin_function_or_method
Base Class:     <type 'builtin_function_or_method'>
String Form:    <built-in method isqrt of sage.rings.integer.Integer
object at 0xc008800>
Namespace:      Interactive
Source:
    def isqrt(self):
        r"""
        Returns the integer floor of the square root of self, or raises
        an \exception{ValueError} if self is negative.

        EXAMPLE:
            sage: a = Integer(5)
            sage: a.isqrt()
            2

            sage: Integer(-102).isqrt()
            Traceback (most recent call last):
            ...
            ValueError: square root of negative integer not defined.
        """
        if mpz_sgn(self.value) < 0:
            raise ValueError, "square root of negative integer not defined."
        cdef Integer x
        x = PY_NEW(Integer)

        _sig_on
        mpz_sqrt(x.value, self.value)
        _sig_off

        return x

Better support for epydoc could be a good goal for cython...

> >> Too bad your mailing list is on Google. The "contract" you have to
> >> sign in
> >> Mailman is a no-brainer. I'm not going to read through a contract with 20
> >> sections + subsections + whatnot just to subscribe to a mailing list.
> >
> > So your answer is: "no, I will not help out or join the mailing list if
> > it is hosted by Google, but I would if it were Mailman"?
>
> Sort of. I'm not sure I can handle a second OSS project currently besides my
> employment and lxml (where I'm the primary maintainer).

I understand!  Maybe you can at least look at the mailing list via
the web-based interface sometimes...

> But at least I can offer to help get my patches ready for inclusion and make
> SageX build lxml.

Excellent.  Thanks.

> Anyway, there are enough places that get you a decent web site, code
> repository and mailing list out there. You might even consider coming to
> codespeak.net, where PyPy and lxml are hosted.
>
> http://codespeak.net/
>
> Not the most feature rich place in the world, but nice people who support it.

I'll check it out.  Probably I'll use my own hosting tools and have
some mirrors elsewhere (maybe at codespeak.net?)

William



More information about the Pyrex mailing list