Re: GSoC idea: mypyc as an alternative to cython

2022-05-25 Thread Chad Dombrova
>
> - What does the new prototype code look like (hopefully much cleaner)?
>

Instead of a separate pxd file, you just have the existing .py file with
standard typing annotations.


> - How does performance compare to the Cython approach?
>

Good question.  I've not been able to find any posts with comparisons.
mypyc maintains a benchmark repo with results compared to standard
cpython:
https://github.com/mypyc/mypyc-benchmark-results/blob/master/reports/summary-main.md

Running these benchmarks against cython could be a good first task.

Unlike Cython, mypyc doesn’t natively support numpy, but IIRC beam is not
using that in its cythonized modules.

-chad


Re: GSoC idea: mypyc as an alternative to cython

2022-05-25 Thread Sam Bourne
Is there any interest in this? There is a lot of promise in only needing to
maintain a single well typed implementation.

On Fri, Feb 11, 2022 at 6:35 PM Chad Dombrova  wrote:

> Hi all,
> At work, I recently started playing around with mypyc[1] as a means to
> compile our python code to C extensions, and I'm pretty impressed so far.
>
> Pros
>
>- write normal python code with annotations:  we're already doing this!
>- no need for cython-specific header files that can get out of sync
>with the pure python version
>- support for dataclasses and Generics
>- one less tool in the toolchain: mypyc is part of mypy
>- opens the door to more easily converting additional modules in the
>future
>
> Cons
>
>- less mature than Cython
>- build errors are not very informative
>
> Neural
>
>- requires more detailed annotations.  for example, you must annotate
>class attributes with ClassVar
>
> I thought it would be an interesting and relatively accessible project to
> try to convert the current modules that use cython over to mypyc and see
> how it goes.  Just a thought: take it or leave it!
>
> -chad
>
> [1] https://mypyc.readthedocs.io/en/latest/introduction.html
>
>


GSoC idea: mypyc as an alternative to cython

2022-02-11 Thread Chad Dombrova
Hi all,
At work, I recently started playing around with mypyc[1] as a means to
compile our python code to C extensions, and I'm pretty impressed so far.

Pros

   - write normal python code with annotations:  we're already doing this!
   - no need for cython-specific header files that can get out of sync with
   the pure python version
   - support for dataclasses and Generics
   - one less tool in the toolchain: mypyc is part of mypy
   - opens the door to more easily converting additional modules in the
   future

Cons

   - less mature than Cython
   - build errors are not very informative

Neural

   - requires more detailed annotations.  for example, you must annotate
   class attributes with ClassVar

I thought it would be an interesting and relatively accessible project to
try to convert the current modules that use cython over to mypyc and see
how it goes.  Just a thought: take it or leave it!

-chad

[1] https://mypyc.readthedocs.io/en/latest/introduction.html