Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Sorry, I have to ask...

Does it support also braces? :)

IIUC the source is writen as a long heresting and then executed.

Does it have the same speed than normal Python?

Does it suppont numpy, numba and other similar packages that use jit?

Can a function inside the modified code call a function outside? (It may be helpful for porting conde one function at a time.)

Is it possible to do something similar with a decorator instead of a herestring?



(This sort of thing has been done before, and of course it will never make its way into the official Python distribution; but it's always fun to see.)

>Is it possible to do something similar with a decorator instead of a herestring?

No, this is a fundamental change to Python syntax. To apply a decorator to existing Python code, the decorated code has to compile first, creating a Python object (generally either a function object or "type" i.e. class object) which is passed to the decorator (which is really just a higher-order function with special syntactic support).

But of course, you could write the code to preprocess in a separate file with a different extension, and then have actual Python code which reads and preprocesses it and then evals the result. (The internals could also be written differently, in terms of AST manipulations using the "compiler services" part of the standard library. But this way is probably easier.)

On Linux, you could also have a top-level script which does those steps for a specified input filename, and then specify that script in the shebang line for the Dopy code file.


> Does it also support braces? No :)

> the source is written as a long herestring and then executed that's correct but only for single file modules. you can actually have a python like structure comprising entirely of dopy files and it will be compiled in place or in temp dir and executed as a normal python package with distributed source

> Does it have the same speed than normal Python It's just a transpiler so the code is actually executed by the python interpreter itself. So same speed as python with an extra build step

> Does it support numpy, numba, other packages that use jit? Not now

> Can a function inside the modified... Certainly

> Is it possible to do something similar with a decorator instead of a herestring? Could you explain?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: