Dear All

Python is a "glue" language, its dynamic nature has programming advantage and 
performance disadvantage.

The best way to use Python is write Python code for high-level stuff and use 
native programming language like C, Rust, Zig, V for low level stuff. 
Currently, there is library like PyO3 and so on.

However there is a lot of limitation in those library.

- The "FFI" library is implementation specific. For example, PyO3, it highly 
depend on specific version of CPython. If you use a different version of 
CPython, there is some work for you to do. If you don't use CPython, for 
example use another Python Implementation, This framework may not work.
- The project structure is rigid. When using something like PyO3. you must make 
your project structure following certain pattern, then finally produce a 
complete wheel package. The majority Python programmer does not write a whole 
Python project for a installable package and pack it up then install it. They 
are edit Python source file iteratively and run it locally.
- It is really ridiculous when you want to stick some item on the wall. You 
need to totally redesign this item and manufacture a new item to fit the glue 
you are going to use. As a glue language, Python should be designed to glue 
other native programming language as a feature of Python programming language 
itself not the tricks of certain variant of implementation.

It would be nice to add the feature in Python Standards (no matter what 
implementation is used) to satisfy the following capabilities:

- The interface is universal across all variant and version of Python 
implementation (There might be protocol version update and may not 
backward-compatible, but it is not bounded with Python implementation). The 
overall effect is in some extent like JSON, but it is not a structured string, 
It is a lively data structure with in-memory representation, they are unified 
no matter what Python variant is used and what low level native language is 
used.
- This mechanism is transparent to users, there is modules in standard library 
to support it. If user want, they can design a toy native programming language, 
and use Python to write a compiler for it. Then write a module with custom 
language then compile and import it. This mechanism provide user with maximum 
flexibility.
- almost zero-cost abstraction. Even if it not depend on CPython tricks. But 
the central idea of this mechanism is still the dynamic linking feature 
provided by operating system. The detailed format will be slightly different. 
It doesn't introduce new stuff in nature. It doesn't spawn new process, nor 
launch a VM, and nor I/O operations is involved. It just make some basic data 
representation conversion and invoke the method in dynamic library.

This is just a raw idea. If it is valuable, it can take a discussion and make 
further steps.

Thanks
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/R2NBDZHCCTJNRN27XP7PY7QLKDLYKSAW/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to