Snowball to Python compiler

Discussion in 'Python' started by Matt Chaput, Apr 21, 2011.

  1. Matt Chaput

    Matt Chaput Guest

    On the slim chance that (a) somebody worked on something like this but
    never uploaded it to PyPI, and (b) the person who did (a) or heard about
    it is reading this list ;) --

    I'm looking for some code that will take a Snowball program and compile
    it into a Python script. Or, less ideally, a Snowball interpreter
    written in Python.

    (http://snowball.tartarus.org/)

    Anyone heard of such a thing?

    Thanks!

    Matt
    Matt Chaput, Apr 21, 2011
    #1
    1. Advertising

  2. Matt Chaput

    Paul Rubin Guest

    Matt Chaput <> writes:
    > I'm looking for some code that will take a Snowball program and
    > compile it into a Python script. Or, less ideally, a Snowball
    > interpreter written in Python.
    >
    > (http://snowball.tartarus.org/)
    >
    > Anyone heard of such a thing?


    I never saw snowball before, it looks kind of interesting, and it
    looks like it already has a way to compile to C. If you're using
    it for IR on any scale, you're surely much better off using the C
    routines with a C API wrapper, than translating snowball to
    Python, which will be dog slow to interpret.
    Paul Rubin, Apr 22, 2011
    #2
    1. Advertising

  3. Matt Chaput

    Terry Reedy Guest

    On 4/21/2011 8:25 PM, Paul Rubin wrote:
    > Matt Chaput<> writes:
    >> I'm looking for some code that will take a Snowball program and
    >> compile it into a Python script. Or, less ideally, a Snowball
    >> interpreter written in Python.
    >>
    >> (http://snowball.tartarus.org/)
    >>
    >> Anyone heard of such a thing?

    >
    > I never saw snowball before, it looks kind of interesting, and it
    > looks like it already has a way to compile to C. If you're using
    > it for IR on any scale, you're surely much better off using the C
    > routines with a C API wrapper,


    If the C routines are in a shared library, you should be able to write
    the interface in Python with ctypes.

    > than translating snowball to
    > Python, which will be dog slow to interpret.



    --
    Terry Jan Reedy
    Terry Reedy, Apr 22, 2011
    #3
  4. Terry Reedy, 22.04.2011 05:48:
    > On 4/21/2011 8:25 PM, Paul Rubin wrote:
    >> Matt Chaput writes:
    >>> I'm looking for some code that will take a Snowball program and
    >>> compile it into a Python script. Or, less ideally, a Snowball
    >>> interpreter written in Python.
    >>>
    >>> (http://snowball.tartarus.org/)
    >>>
    >>> Anyone heard of such a thing?

    >>
    >> I never saw snowball before, it looks kind of interesting, and it
    >> looks like it already has a way to compile to C. If you're using
    >> it for IR on any scale, you're surely much better off using the C
    >> routines with a C API wrapper,

    >
    > If the C routines are in a shared library, you should be able to write the
    > interface in Python with ctypes.


    Since it appears that the code has to get compiled anyway, Cython is likely
    a better option, as it makes it easier to write a fast and Pythonic wrapper.

    From a quick look, Snowball also has a "-widechar" option that could allow
    interfacing directly with Python's Unicode strings in 16-bit Unicode builds
    (but not 32-bit builds!). That would provide for really fast wrappers that
    do not even need an intermediate encoding step. And PEP 393 would
    eventually allow to include both a UTF-8 and a 16-bit version of the
    (prefixed) Snowball code, and to use them alternatively, depending on the
    internal layout of the processed string, with the obvious fallback to UTF-8
    encoding only for strings that really exceed the lower 16-bit Unicode range.

    That sounds like a really nice project.

    Stefan
    Stefan Behnel, Apr 22, 2011
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Yan
    Replies:
    0
    Views:
    1,132
  2. Jack Wright
    Replies:
    5
    Views:
    623
    Shiv Kumar
    Jan 19, 2004
  3. Ram
    Replies:
    0
    Views:
    2,831
  4. Andrey Batyuck

    Compiler compiler with C++ as output

    Andrey Batyuck, May 11, 2004, in forum: C++
    Replies:
    3
    Views:
    437
    Frederik Hertzum
    May 17, 2004
  5. Gerwin
    Replies:
    0
    Views:
    172
    Gerwin
    Feb 6, 2007
Loading...

Share This Page