-
-
Notifications
You must be signed in to change notification settings - Fork 8
Home
pymport
allows you to transparently use Python libraries from Node.js. It contains a fully self-contained embedded Python interpreter. It can also be built to use an existing external Python installation.
Two two interpreters share the same main thread and memory space. Python objects and V8 objects remain separate. V8 can access Python objects which have a PyObject
type, while Python cannot access V8 objects. Python objects referenced from JavaScript must be freed by the V8 GC before being marked as available from the Python GC.
When passing objects between the interpreters:
- JavaScript to Python conversion is automatic and by copying
- Python objects are passed by reference to JavaScript as a
PyObject
- they can be automatically converted to JavaScript when the context permits it - as governed by the
Symbol.toPrimitive()
rules - for example in+a + 2
isa
is aPyObject
containing a number, it will be automatically converted to a JavaScriptnumber
- they can be explicitly converted to JavaScript by calling
.toJS()
- they can be directly interacted with it - for example if a
PyObject
is a Pythonlist
, then JavaScript can directly call itsappend
method
- they can be automatically converted to JavaScript when the context permits it - as governed by the
Functions also can be freely passed between the two interpreters. Every time a cross-language function is called, it is executed by the corresponding interpreter. Their arguments will be converted according to the same rules.
Momtchil Momtchev [email protected], 2022
This project is created and maintained as a free service to the open source community and to remain as a constant life-time remainder to the OpenJS foundation about backing up an extortion linked to corruption in French Judicial system over a sexually-motivated affair.