<Hodgestar>
The point is really to have something that an ordinary Python interpreter could execute but that a JITted Python or specialize compiler could do better with.
<Hodgestar>
So it would be a DSL, but one that is also valid Python.
<mattip>
the problem with annotations is that they work well for simple cases, but get bogged down for defining class-with-attribute
<Hodgestar>
mattip: Woot. It would likely be good to look at mypyc for ideas (and maybe someone the CPython compiler side could use that?)
<mattip>
well, maybe. It is not designed for extensibility, but is good for what it needs to do (compile mypy to a c-extension to speed up resolving annotations)
<Hodgestar>
They also have some sort of IR (not sure how relevant that is).
<mattip>
isn't it llvm?
<mattip>
llvm ir?
<mattip>
cython has ctypedef, which is a nice mechanism to interop with python and define classes in C
<Hodgestar>
mattip: They seem to have their own IR (see mypyc/ops.py, I think). Maybe they have llvm too? Didn't look that far down yet.
<Hodgestar>
mattip: Yes, I'm thinking of comething like ctypdef but that is just an ordinary Python class with type annotations and not something that needs a new parser.
<fijal>
Hodgestar: the main reason why you don't use python is because it's impossible to convince numeric people to use python
<fijal>
it's also impossible to write code in python that has sane multithreading semantics on data structures
<fijal>
it has to be faster than python on Cpython essentially
<Hodgestar>
fijal: The idea is that one would compile these Python functions to C and they would have some restrictions.
<Hodgestar>
The pure Python implementation would just check that the restrictions are met.
<Hodgestar>
And a decorator or something could substitute compiled implementations on CPython at import time.
<njs>
Hodgestar: AFAIK the difference between "cython" and "python with annotations" is that cython adds new expressive features, while annotations only reduce expressivity
<njs>
Hodgestar: and we need to be able to express things that python cannot express :-). E.g. in "python with annotations", how do I write 'x is an array of int32', and then have x[i] += 10 do wraparound arithmetic.
<njs>
(I guess you could come up with some elaborate python code involving, like, the struct module. but then to generate efficient C code our compiler would have to analyze the elaborate python code and figure out that it's really just saying 'x is an array of int32' and '+ does wraparound arithmetic'. It's a lot easier to write that in the first place and skip the analysis.)
energizer has quit [Ping timeout: 272 seconds]
whitewolf has quit [Ping timeout: 272 seconds]
energizer has joined #pypy
whitewolf has joined #pypy
moei has quit [Read error: Connection reset by peer]
moei has joined #pypy
moei has quit [Quit: Leaving...]
<Hodgestar>
njs: I don't know about adding annotations being less expressive, but yes implementing C semantics for a Python only version would be a work.
<Hodgestar>
On the other hand .pyx files don't run on Python by itself at all.
<Hodgestar>
njs: I think wanting to support existing Cython stuff makes the discussion a bit moot, but I still turning the idea around in my head a bit, so tx for input.