Python binding for QuickJS using CFFI
Project description
quickjs-cffi
Python binding for QuickJS Javascript Engine using cffi. Supports x86_64 and aarch64 platforms.
NOTE: Currently supported operating system is Linux (manylinux_2_28 and musllinux_1_2)
Install
pip install quickjs-cffi
Features
- ✅ Use npm to install packages and use them directly
- ✅ In case you need to use complex ECMAScript or TypeScript modules/libraries/packages see Yjs example below how to use esbuild to transpile their code to QuickJS compatible ECMAScript modules
- ✅ Import remote and local ECMAScript scripts/modules
- ✅ Define Python objects and pass them to JavaScript
- ✅ Define JavaScript objects and pass them to Python
- ✅ Python objects live in Python environment
- ✅ JavaScript objects live in JavaScript environment
- ✅ Freely use Python objects in JavaScript
- ✅ Freely use JavaScript objects in Python
Usage
from quickjs import JSEval, JSRuntime, JSContext, JSError
# create runtime and context
rt = JSRuntime()
ctx: JSContext = rt.new_context()
# load lodash from remote location
# it also accepts local JavaScript files
ctx.load('https://raw.githubusercontent.com/lodash/lodash/refs/heads/main/dist/lodash.min.js')
lodash: JSValue = ctx['_']
# call lodash.range to create array JavaScript side
# and return its handler to Python side
r: JSValue = lodash.range(10, 100, 10)
# on Python side, define JavaScript function
# and use it to filter JavaScript array
f0: JSValue = ctx.eval('n => n >= 50')
r: JSValue = lodash.filter(lodash.range(10, 100, 10), f0)
# on Python side, define Python function
# and use on JavaScript side to filter array
def f1(n, *args):
return n >= 50
r: JSValue = lodash.filter(lodash.range(10, 100, 10), f1)
# on Python side, define Python lambda function
# and use on JavaScript side to filter array
f2 = lambda n, *args: n >= 50 # noqa
r: JSValue = lodash.filter(lodash.range(10, 100, 10), f2)
# on Python side, define pass inplace Python lambda function
# and use on JavaScript side to filter array
r: JSValue = lodash.filter(lodash.range(10, 100, 10), lambda n, *args: n >= 50)
# on Python side, define Python lambda function
# then set it as global function in JavaScript
# and use it on JavaScript side to filter array
ctx['f3'] = lambda n, *args: n >= 50
r: JSValue = lodash.filter(lodash.range(10, 100, 10), ctx.eval('f3'))
Build
python -m venv venv
source venv/bin/activate
pip install poetry
poetry install --all-extras
Demos
First setup temp node project, so node modules can be installed and used inside QuickJS examples:
npm init -y
npm install esbuild
Huge number of isoloted JavaScript contexts:
python -B examples/demo_contexts.py
Lodash example:
npm install lodash
python -B examples/demo_lodash.py
Handlebas example:
npm install handlebars
python -B examples/demo_handlebars.py
Yjs example:
npm install yjs
esbuild node_modules/yjs/src/index.js --bundle --outfile=examples/yjs.js --format=iife --loader:.ts=ts --global-name="Y"
python -B examples/demo_yjs.py
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file quickjs_cffi-0.1.3-pp310-pypy310_pp73-manylinux_2_28_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: quickjs_cffi-0.1.3-pp310-pypy310_pp73-manylinux_2_28_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 2.0 MB
- Tags: PyPy, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.12.7 Linux/6.12.1-arch1-1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f85a44a638b8db4b0bd8ef1a0bf25965cd14d8a6bf94eddc40d4cd686f68a151
|
|
| MD5 |
9cf7101aaf518435846c220159ee730b
|
|
| BLAKE2b-256 |
64f27fe57f7e891075caf0087bb135e8eab4ed3e78ccaf20d092bc6558110864
|
File details
Details for the file quickjs_cffi-0.1.3-pp310-pypy310_pp73-manylinux_2_28_aarch64.manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: quickjs_cffi-0.1.3-pp310-pypy310_pp73-manylinux_2_28_aarch64.manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 1.9 MB
- Tags: PyPy, manylinux: glibc 2.17+ ARM64, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.12.7 Linux/6.12.1-arch1-1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
263cf3f62fb055b3a9266d95768b628fc09de96c46fb2cba72f138c33ef5c768
|
|
| MD5 |
0fcb7a78bc5e145dc5ee07c4de502301
|
|
| BLAKE2b-256 |
1fd20348e95e3653c0b1aa3e3e385461b3a8d4f58a00e95e2c88280ff4663d93
|
File details
Details for the file quickjs_cffi-0.1.3-cp313-cp313-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: quickjs_cffi-0.1.3-cp313-cp313-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 2.1 MB
- Tags: CPython 3.13, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.12.7 Linux/6.12.1-arch1-1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c863c072d85b712051ab98603215e0cf1e54e045c8fc1a47d9bafc21b739f56e
|
|
| MD5 |
afe9adfb112db0726a8656b81bf6a699
|
|
| BLAKE2b-256 |
f94324a5bf732404601be8a0f6c80097ade0fd3e09e6518564a577025ebef6a3
|
File details
Details for the file quickjs_cffi-0.1.3-cp313-cp313-musllinux_1_2_aarch64.whl.
File metadata
- Download URL: quickjs_cffi-0.1.3-cp313-cp313-musllinux_1_2_aarch64.whl
- Upload date:
- Size: 2.1 MB
- Tags: CPython 3.13, musllinux: musl 1.2+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.12.7 Linux/6.12.1-arch1-1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
afaac20d6816ccdde714f2f7a096633b4e0e43a16b6dcf8dd59d6c8fef0fc4fa
|
|
| MD5 |
5d1a65af91c5f1c155f56ee3cd25c602
|
|
| BLAKE2b-256 |
ea109ae400062fa58b818c236a1b34cfb03f0af1d42c840ce078781f7e9a702d
|
File details
Details for the file quickjs_cffi-0.1.3-cp313-cp313-manylinux_2_28_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: quickjs_cffi-0.1.3-cp313-cp313-manylinux_2_28_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 2.2 MB
- Tags: CPython 3.13, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.12.7 Linux/6.12.1-arch1-1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
50c8b59d6096f06594128d3ece82e3168e03376cec4a68de0a8f51baedab546b
|
|
| MD5 |
38c508e507b7fe190ea37cbdee4abc37
|
|
| BLAKE2b-256 |
209a7c853b9820b761304444501cc404a2b8ec01d36a50eb8481dfd564476698
|
File details
Details for the file quickjs_cffi-0.1.3-cp313-cp313-manylinux_2_28_aarch64.manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: quickjs_cffi-0.1.3-cp313-cp313-manylinux_2_28_aarch64.manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 2.2 MB
- Tags: CPython 3.13, manylinux: glibc 2.17+ ARM64, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.12.7 Linux/6.12.1-arch1-1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8cfb30b7d7643ba0b9c612f774c7b8805936e0594c9b931855384d79138e24bc
|
|
| MD5 |
237726edfaded8d32aee64576657e940
|
|
| BLAKE2b-256 |
69a6b3bdf2a6c0964c9fb2abd795823ea78358db61811adb69894fc458076a14
|
File details
Details for the file quickjs_cffi-0.1.3-cp312-cp312-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: quickjs_cffi-0.1.3-cp312-cp312-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 2.1 MB
- Tags: CPython 3.12, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.12.7 Linux/6.12.1-arch1-1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a1c88946f620205380f47d9ce6efe89804bdbf3653f9d878ad587e1ec30b24c0
|
|
| MD5 |
1ff2ab10f05453f82d872bd6d2eb9c8a
|
|
| BLAKE2b-256 |
fd83e4af7e43411b35a9cbf3fb623661f9f172f064a78a1c49fc15c45c455d26
|
File details
Details for the file quickjs_cffi-0.1.3-cp312-cp312-musllinux_1_2_aarch64.whl.
File metadata
- Download URL: quickjs_cffi-0.1.3-cp312-cp312-musllinux_1_2_aarch64.whl
- Upload date:
- Size: 2.1 MB
- Tags: CPython 3.12, musllinux: musl 1.2+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.12.7 Linux/6.12.1-arch1-1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e8c3da920d39a521a85165eb8f6de6fb1fcb53e70ef7cec3c385a5968295fa40
|
|
| MD5 |
b517a376280db4f91f08f5890fd68fd0
|
|
| BLAKE2b-256 |
933e38fc5befa1e1e87d06c2b6ef34975c92107efef550f18239d3df4101549a
|
File details
Details for the file quickjs_cffi-0.1.3-cp312-cp312-manylinux_2_28_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: quickjs_cffi-0.1.3-cp312-cp312-manylinux_2_28_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 2.2 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.12.7 Linux/6.12.1-arch1-1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bc239d1e40a7a6e9721340aa95b660c0cdf26bffab1c59444165299611915c4c
|
|
| MD5 |
3c55d5d19c818380297d8caa4746a9cd
|
|
| BLAKE2b-256 |
5cb9a1b58cc70e8cd86012830919f339e6483d33a905947e954ad09fe1047b41
|
File details
Details for the file quickjs_cffi-0.1.3-cp312-cp312-manylinux_2_28_aarch64.manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: quickjs_cffi-0.1.3-cp312-cp312-manylinux_2_28_aarch64.manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 2.2 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ ARM64, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.12.7 Linux/6.12.1-arch1-1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d6a4462d091936ff5296cf6de179a1c3e01c9cead18ae17b9de99d6cdee1d131
|
|
| MD5 |
e778741d79f8693ed6cfdc6696b849fa
|
|
| BLAKE2b-256 |
c9bca2b085280847cbc06d82f25c4e09db46fa8dbe3867c13f83e963894d3e63
|
File details
Details for the file quickjs_cffi-0.1.3-cp311-cp311-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: quickjs_cffi-0.1.3-cp311-cp311-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 2.1 MB
- Tags: CPython 3.11, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.12.7 Linux/6.12.1-arch1-1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a94c98cc4e9d6425bb0e9419d4d39f0127eab95a548ddd538bf1ad6feebf0e27
|
|
| MD5 |
db304b876159ddfbe374179af9cdb855
|
|
| BLAKE2b-256 |
2c29cc7e0cd3c38a0a1b07c7e52c791d67343d7bc5e0058f3a8da7703f6d399c
|
File details
Details for the file quickjs_cffi-0.1.3-cp311-cp311-musllinux_1_2_aarch64.whl.
File metadata
- Download URL: quickjs_cffi-0.1.3-cp311-cp311-musllinux_1_2_aarch64.whl
- Upload date:
- Size: 2.1 MB
- Tags: CPython 3.11, musllinux: musl 1.2+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.12.7 Linux/6.12.1-arch1-1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2d37bc49b09596d969bc0d76beb4b64dc8d57e7f696da916744a54ee3478b4f7
|
|
| MD5 |
f2e2e032282a644e98cbdd156a4fde08
|
|
| BLAKE2b-256 |
46fa2a1388565e3c9ee0b888b5470a92f09d3e257d4f767804e149d7e2c4d512
|
File details
Details for the file quickjs_cffi-0.1.3-cp311-cp311-manylinux_2_28_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: quickjs_cffi-0.1.3-cp311-cp311-manylinux_2_28_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 2.2 MB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.12.7 Linux/6.12.1-arch1-1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2084e3f051c4da5cc2e2d46eda05a1082b279906bf1eaed707d4e08f320250a2
|
|
| MD5 |
c0d061ede3d563feb3ca3d5a9caaf69d
|
|
| BLAKE2b-256 |
b5c25d9cab6be4bc86b16882ba6a947bd94f936a0f74249bd9f868775f25c778
|
File details
Details for the file quickjs_cffi-0.1.3-cp311-cp311-manylinux_2_28_aarch64.manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: quickjs_cffi-0.1.3-cp311-cp311-manylinux_2_28_aarch64.manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 2.2 MB
- Tags: CPython 3.11, manylinux: glibc 2.17+ ARM64, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.12.7 Linux/6.12.1-arch1-1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
01077959d7302ec538fdf35169186fc33b40c8fa08f2fb02803ba8a221dffd86
|
|
| MD5 |
3eb95c27c3e0d3bc25b9c0fe19d671b0
|
|
| BLAKE2b-256 |
bb9a2a3f9b96a41d40de9fca543912a23a75d54a846f4c80d71e1a379544550e
|
File details
Details for the file quickjs_cffi-0.1.3-cp310-cp310-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: quickjs_cffi-0.1.3-cp310-cp310-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 2.1 MB
- Tags: CPython 3.10, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.12.7 Linux/6.12.1-arch1-1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d31c114951973d4d5f31ef46658b4451564af2cd4573caf3588d19f79336047e
|
|
| MD5 |
e6cbe192b9f31a9d371c628faf6b34ab
|
|
| BLAKE2b-256 |
c00b64b56cb22d13b54b0401523ce2fb35f1920f1e7fc342fda3f2b28533e1cb
|
File details
Details for the file quickjs_cffi-0.1.3-cp310-cp310-musllinux_1_2_aarch64.whl.
File metadata
- Download URL: quickjs_cffi-0.1.3-cp310-cp310-musllinux_1_2_aarch64.whl
- Upload date:
- Size: 2.1 MB
- Tags: CPython 3.10, musllinux: musl 1.2+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.12.7 Linux/6.12.1-arch1-1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9dca0831aeb86ae3e5b18b2231aca36262f4eabf7bef88f044fee724e46a50a5
|
|
| MD5 |
c590759027b62ffde96d489a8e48ce16
|
|
| BLAKE2b-256 |
a219067e6f3f1bf8a2057771a0b097078c89a3d7e4c5e5bacee776d601ed7cee
|
File details
Details for the file quickjs_cffi-0.1.3-cp310-cp310-manylinux_2_28_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: quickjs_cffi-0.1.3-cp310-cp310-manylinux_2_28_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 2.2 MB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.12.7 Linux/6.12.1-arch1-1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
66b8ed319b6df71475ae925d9b963c2bcbd35851936d93f2e806a36d6bf51eff
|
|
| MD5 |
48eb13cf9a279e484343345109411b5f
|
|
| BLAKE2b-256 |
3e042fbb96c30c81489a50c7079335c15a40c30ffb6d8bf1250078c0fe4894b3
|
File details
Details for the file quickjs_cffi-0.1.3-cp310-cp310-manylinux_2_28_aarch64.manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: quickjs_cffi-0.1.3-cp310-cp310-manylinux_2_28_aarch64.manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 2.2 MB
- Tags: CPython 3.10, manylinux: glibc 2.17+ ARM64, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.12.7 Linux/6.12.1-arch1-1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
caec37e2d8059f2896eb07e78f8d044d27fb8b3d658514334bbd0c66f69c927d
|
|
| MD5 |
c90f7725a2d6dfeab26faf468bb3b7c6
|
|
| BLAKE2b-256 |
990649811f019cf923363e842d052dab362ade95b6be32045ca77fc6df26d7ca
|