concurrent-c-node 0.2.0__tar.gz → 0.2.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {concurrent_c_node-0.2.0 → concurrent_c_node-0.2.1}/PKG-INFO +7 -4
- {concurrent_c_node-0.2.0 → concurrent_c_node-0.2.1}/README.md +6 -3
- concurrent_c_node-0.2.1/cc_node/examples/__init__.py +0 -0
- concurrent_c_node-0.2.1/cc_node/examples/bench_wire.py +47 -0
- concurrent_c_node-0.2.1/cc_node/examples/use_node.py +32 -0
- {concurrent_c_node-0.2.0 → concurrent_c_node-0.2.1}/concurrent_c_node.egg-info/PKG-INFO +7 -4
- {concurrent_c_node-0.2.0 → concurrent_c_node-0.2.1}/concurrent_c_node.egg-info/SOURCES.txt +3 -0
- {concurrent_c_node-0.2.0 → concurrent_c_node-0.2.1}/pyproject.toml +3 -2
- {concurrent_c_node-0.2.0 → concurrent_c_node-0.2.1}/cc_node/__init__.py +0 -0
- {concurrent_c_node-0.2.0 → concurrent_c_node-0.2.1}/cc_node/broker.cjs +0 -0
- {concurrent_c_node-0.2.0 → concurrent_c_node-0.2.1}/concurrent_c_node.egg-info/dependency_links.txt +0 -0
- {concurrent_c_node-0.2.0 → concurrent_c_node-0.2.1}/concurrent_c_node.egg-info/top_level.txt +0 -0
- {concurrent_c_node-0.2.0 → concurrent_c_node-0.2.1}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: concurrent-c-node
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.1
|
|
4
4
|
Summary: JavaScript and npm packages from Python over the Concurrent-C bridge: one spawned Node child per domain, host-controlled lifetime.
|
|
5
5
|
License: MIT
|
|
6
6
|
Project-URL: Repository, https://github.com/sreekotay/concurrent-c
|
|
@@ -40,9 +40,11 @@ array in **9ms** where the same values as a JSON list take 583ms.
|
|
|
40
40
|
|
|
41
41
|
```
|
|
42
42
|
pip install concurrent-c-node # needs node on PATH (or point at one)
|
|
43
|
+
python -m cc_node.examples.use_node
|
|
44
|
+
python -m cc_node.examples.bench_wire
|
|
43
45
|
```
|
|
44
46
|
|
|
45
|
-
Import stays `import cc_node`. The mirror of
|
|
47
|
+
Import stays `import cc_node`. Examples ship in the wheel. The mirror of
|
|
46
48
|
[`concurrent-c-python`](https://github.com/sreekotay/concurrent-c/tree/main/npm/cc-python)
|
|
47
49
|
— same domain model, same materialization rules, pointed the other way:
|
|
48
50
|
|
|
@@ -119,7 +121,8 @@ next to your program is the whole setup.
|
|
|
119
121
|
|
|
120
122
|
## Measured
|
|
121
123
|
|
|
122
|
-
From
|
|
124
|
+
From `python -m cc_node.examples.bench_wire` (sources under
|
|
125
|
+
[`cc_node/examples/`](https://github.com/sreekotay/concurrent-c/blob/main/pypi/cc-node/cc_node/examples/))
|
|
123
126
|
on a 4-vCPU x86-64 box, node 22 / python 3.11 (dated baselines under
|
|
124
127
|
`perf/baselines/` in the repo):
|
|
125
128
|
|
|
@@ -138,7 +141,7 @@ future work.
|
|
|
138
141
|
|
|
139
142
|
A worked tour (builtin Node modules, chains, callbacks, thenables,
|
|
140
143
|
buffers — no npm install needed):
|
|
141
|
-
|
|
144
|
+
`python -m cc_node.examples.use_node`.
|
|
142
145
|
|
|
143
146
|
And when the hot path is YOUR code rather than an npm package, skip the
|
|
144
147
|
wire entirely: a page of Concurrent-C (or C) exports as a native module
|
|
@@ -29,9 +29,11 @@ array in **9ms** where the same values as a JSON list take 583ms.
|
|
|
29
29
|
|
|
30
30
|
```
|
|
31
31
|
pip install concurrent-c-node # needs node on PATH (or point at one)
|
|
32
|
+
python -m cc_node.examples.use_node
|
|
33
|
+
python -m cc_node.examples.bench_wire
|
|
32
34
|
```
|
|
33
35
|
|
|
34
|
-
Import stays `import cc_node`. The mirror of
|
|
36
|
+
Import stays `import cc_node`. Examples ship in the wheel. The mirror of
|
|
35
37
|
[`concurrent-c-python`](https://github.com/sreekotay/concurrent-c/tree/main/npm/cc-python)
|
|
36
38
|
— same domain model, same materialization rules, pointed the other way:
|
|
37
39
|
|
|
@@ -108,7 +110,8 @@ next to your program is the whole setup.
|
|
|
108
110
|
|
|
109
111
|
## Measured
|
|
110
112
|
|
|
111
|
-
From
|
|
113
|
+
From `python -m cc_node.examples.bench_wire` (sources under
|
|
114
|
+
[`cc_node/examples/`](https://github.com/sreekotay/concurrent-c/blob/main/pypi/cc-node/cc_node/examples/))
|
|
112
115
|
on a 4-vCPU x86-64 box, node 22 / python 3.11 (dated baselines under
|
|
113
116
|
`perf/baselines/` in the repo):
|
|
114
117
|
|
|
@@ -127,7 +130,7 @@ future work.
|
|
|
127
130
|
|
|
128
131
|
A worked tour (builtin Node modules, chains, callbacks, thenables,
|
|
129
132
|
buffers — no npm install needed):
|
|
130
|
-
|
|
133
|
+
`python -m cc_node.examples.use_node`.
|
|
131
134
|
|
|
132
135
|
And when the hot path is YOUR code rather than an npm package, skip the
|
|
133
136
|
wire entirely: a page of Concurrent-C (or C) exports as a native module
|
|
File without changes
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"""The cc-node wire, measured. RESULT lines are machine-comparable.
|
|
2
|
+
|
|
3
|
+
python -m cc_node.examples.bench_wire
|
|
4
|
+
"""
|
|
5
|
+
import array
|
|
6
|
+
import time
|
|
7
|
+
|
|
8
|
+
import cc_node
|
|
9
|
+
|
|
10
|
+
t0 = time.perf_counter()
|
|
11
|
+
js = cc_node.create()
|
|
12
|
+
js.eval("1")
|
|
13
|
+
print("RESULT spawn_ms %d" % round((time.perf_counter() - t0) * 1000))
|
|
14
|
+
|
|
15
|
+
f = js.eval("(x) => x")
|
|
16
|
+
f(1)
|
|
17
|
+
t0 = time.perf_counter()
|
|
18
|
+
for i in range(500):
|
|
19
|
+
f(i)
|
|
20
|
+
print("RESULT rtt_us %d" % round((time.perf_counter() - t0) / 500 * 1e6))
|
|
21
|
+
|
|
22
|
+
g = js.eval("(cb) => cb(21) * 2")
|
|
23
|
+
g(lambda x: x + 1)
|
|
24
|
+
t0 = time.perf_counter()
|
|
25
|
+
for _ in range(200):
|
|
26
|
+
g(lambda x: x + 1)
|
|
27
|
+
print("RESULT callback_roundtrip_us %d"
|
|
28
|
+
% round((time.perf_counter() - t0) / 200 * 1e6))
|
|
29
|
+
|
|
30
|
+
big = array.array("d", [float(i % 97) for i in range(1 << 20)]) # 8MB
|
|
31
|
+
ln = js.eval("(a) => a.length")
|
|
32
|
+
ln(big)
|
|
33
|
+
t0 = time.perf_counter()
|
|
34
|
+
for _ in range(10):
|
|
35
|
+
ln(big)
|
|
36
|
+
print("RESULT bulk_8mb_shm_ms %.1f" % ((time.perf_counter() - t0) / 10 * 1000))
|
|
37
|
+
|
|
38
|
+
biglist = [float(i % 97) for i in range(1 << 20)]
|
|
39
|
+
ln(biglist)
|
|
40
|
+
t0 = time.perf_counter()
|
|
41
|
+
for _ in range(3):
|
|
42
|
+
ln(biglist)
|
|
43
|
+
print("RESULT bulk_8mb_json_list_ms %d"
|
|
44
|
+
% round((time.perf_counter() - t0) / 3 * 1000))
|
|
45
|
+
|
|
46
|
+
js.destroy()
|
|
47
|
+
print("done")
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"""cc-node in one sitting: builtin Node modules (no npm install needed),
|
|
2
|
+
chains, callbacks both ways, and async-for-free.
|
|
3
|
+
|
|
4
|
+
python -m cc_node.examples.use_node
|
|
5
|
+
"""
|
|
6
|
+
import cc_node
|
|
7
|
+
|
|
8
|
+
with cc_node.create() as js:
|
|
9
|
+
# Builtin modules: attribute access is property lookup, calls are calls.
|
|
10
|
+
path = js.require("path")
|
|
11
|
+
print("join :", path.join("a", "b", "c.txt"))
|
|
12
|
+
|
|
13
|
+
crypto = js.require("crypto")
|
|
14
|
+
print("sha256 :", crypto.createHash("sha256")
|
|
15
|
+
.update("cc-node").digest("hex")[:16], "...")
|
|
16
|
+
|
|
17
|
+
# eval for a quick lambda; a Python callable crosses as a JS function
|
|
18
|
+
# (JS conventions apply: Array.map passes value, index, array).
|
|
19
|
+
mapped = js.eval("(f) => [1, 2, 3].map(f)")(lambda x, *rest: x * 10)
|
|
20
|
+
print("callback :", mapped)
|
|
21
|
+
|
|
22
|
+
# Async is free: thenables are awaited in the child before the reply.
|
|
23
|
+
fetchish = js.eval("async (x) => { return { doubled: x * 2 } }")
|
|
24
|
+
print("thenable :", fetchish(21))
|
|
25
|
+
|
|
26
|
+
# Typed buffers cross as typed arrays (big ones via shared memory);
|
|
27
|
+
# results come back as numpy arrays when numpy is installed.
|
|
28
|
+
total = js.eval("(a) => a.reduce((s, x) => s + x, 0)")
|
|
29
|
+
import array
|
|
30
|
+
print("buffer sum:", total(array.array("d", [1.5, 2.5, 3.0])))
|
|
31
|
+
|
|
32
|
+
print("handles :", js.stats())
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: concurrent-c-node
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.1
|
|
4
4
|
Summary: JavaScript and npm packages from Python over the Concurrent-C bridge: one spawned Node child per domain, host-controlled lifetime.
|
|
5
5
|
License: MIT
|
|
6
6
|
Project-URL: Repository, https://github.com/sreekotay/concurrent-c
|
|
@@ -40,9 +40,11 @@ array in **9ms** where the same values as a JSON list take 583ms.
|
|
|
40
40
|
|
|
41
41
|
```
|
|
42
42
|
pip install concurrent-c-node # needs node on PATH (or point at one)
|
|
43
|
+
python -m cc_node.examples.use_node
|
|
44
|
+
python -m cc_node.examples.bench_wire
|
|
43
45
|
```
|
|
44
46
|
|
|
45
|
-
Import stays `import cc_node`. The mirror of
|
|
47
|
+
Import stays `import cc_node`. Examples ship in the wheel. The mirror of
|
|
46
48
|
[`concurrent-c-python`](https://github.com/sreekotay/concurrent-c/tree/main/npm/cc-python)
|
|
47
49
|
— same domain model, same materialization rules, pointed the other way:
|
|
48
50
|
|
|
@@ -119,7 +121,8 @@ next to your program is the whole setup.
|
|
|
119
121
|
|
|
120
122
|
## Measured
|
|
121
123
|
|
|
122
|
-
From
|
|
124
|
+
From `python -m cc_node.examples.bench_wire` (sources under
|
|
125
|
+
[`cc_node/examples/`](https://github.com/sreekotay/concurrent-c/blob/main/pypi/cc-node/cc_node/examples/))
|
|
123
126
|
on a 4-vCPU x86-64 box, node 22 / python 3.11 (dated baselines under
|
|
124
127
|
`perf/baselines/` in the repo):
|
|
125
128
|
|
|
@@ -138,7 +141,7 @@ future work.
|
|
|
138
141
|
|
|
139
142
|
A worked tour (builtin Node modules, chains, callbacks, thenables,
|
|
140
143
|
buffers — no npm install needed):
|
|
141
|
-
|
|
144
|
+
`python -m cc_node.examples.use_node`.
|
|
142
145
|
|
|
143
146
|
And when the hot path is YOUR code rather than an npm package, skip the
|
|
144
147
|
wire entirely: a page of Concurrent-C (or C) exports as a native module
|
|
@@ -2,6 +2,9 @@ README.md
|
|
|
2
2
|
pyproject.toml
|
|
3
3
|
cc_node/__init__.py
|
|
4
4
|
cc_node/broker.cjs
|
|
5
|
+
cc_node/examples/__init__.py
|
|
6
|
+
cc_node/examples/bench_wire.py
|
|
7
|
+
cc_node/examples/use_node.py
|
|
5
8
|
concurrent_c_node.egg-info/PKG-INFO
|
|
6
9
|
concurrent_c_node.egg-info/SOURCES.txt
|
|
7
10
|
concurrent_c_node.egg-info/dependency_links.txt
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "concurrent-c-node"
|
|
7
|
-
version = "0.2.
|
|
7
|
+
version = "0.2.1"
|
|
8
8
|
description = "JavaScript and npm packages from Python over the Concurrent-C bridge: one spawned Node child per domain, host-controlled lifetime."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.8"
|
|
@@ -16,7 +16,8 @@ Repository = "https://github.com/sreekotay/concurrent-c"
|
|
|
16
16
|
Documentation = "https://github.com/sreekotay/concurrent-c/blob/main/pypi/cc-node/README.md"
|
|
17
17
|
|
|
18
18
|
[tool.setuptools]
|
|
19
|
-
packages = ["cc_node"]
|
|
19
|
+
packages = ["cc_node", "cc_node.examples"]
|
|
20
20
|
|
|
21
21
|
[tool.setuptools.package-data]
|
|
22
22
|
cc_node = ["broker.cjs"]
|
|
23
|
+
"cc_node.examples" = ["*.py"]
|
|
File without changes
|
|
File without changes
|
{concurrent_c_node-0.2.0 → concurrent_c_node-0.2.1}/concurrent_c_node.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{concurrent_c_node-0.2.0 → concurrent_c_node-0.2.1}/concurrent_c_node.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|