psyco3 1.7.0a7__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.
Files changed (52) hide show
  1. psyco3-1.7.0a7/COPYING.txt +9 -0
  2. psyco3-1.7.0a7/MANIFEST.in +3 -0
  3. psyco3-1.7.0a7/PKG-INFO +398 -0
  4. psyco3-1.7.0a7/README.md +372 -0
  5. psyco3-1.7.0a7/benchmarks/automatic.py +121 -0
  6. psyco3-1.7.0a7/benchmarks/call_overhead.py +191 -0
  7. psyco3-1.7.0a7/benchmarks/compare_cinderx.py +242 -0
  8. psyco3-1.7.0a7/benchmarks/data_loops.py +120 -0
  9. psyco3-1.7.0a7/benchmarks/native_loops.py +82 -0
  10. psyco3-1.7.0a7/benchmarks/simd.py +199 -0
  11. psyco3-1.7.0a7/c/ivm/asm-fragment.h +9 -0
  12. psyco3-1.7.0a7/c/py3/asm.h +145 -0
  13. psyco3-1.7.0a7/c/py3/byte-kernels.h +190 -0
  14. psyco3-1.7.0a7/c/py3/cached-tuple.h +67 -0
  15. psyco3-1.7.0a7/c/py3/cpu.h +19 -0
  16. psyco3-1.7.0a7/c/py3/crc-kernels.h +169 -0
  17. psyco3-1.7.0a7/c/py3/field-code.h +82 -0
  18. psyco3-1.7.0a7/c/py3/fields.h +260 -0
  19. psyco3-1.7.0a7/c/py3/function.h +38 -0
  20. psyco3-1.7.0a7/c/py3/grouped-rows.h +193 -0
  21. psyco3-1.7.0a7/c/py3/method-site.h +95 -0
  22. psyco3-1.7.0a7/c/py3/module.c +800 -0
  23. psyco3-1.7.0a7/c/py3/native.h +1161 -0
  24. psyco3-1.7.0a7/c/py3/object-exec.h +1771 -0
  25. psyco3-1.7.0a7/c/py3/object-plan.h +698 -0
  26. psyco3-1.7.0a7/c/py3/portable-asm.h +66 -0
  27. psyco3-1.7.0a7/c/py3/portable.h +273 -0
  28. psyco3-1.7.0a7/c/py3/public.c +144 -0
  29. psyco3-1.7.0a7/c/py3/scalar-x86.h +79 -0
  30. psyco3-1.7.0a7/c/py3/scalar.h +158 -0
  31. psyco3-1.7.0a7/c/py3/simd.h +264 -0
  32. psyco3-1.7.0a7/c/py3/square-kernels.h +71 -0
  33. psyco3-1.7.0a7/c/py3/word-asm.h +85 -0
  34. psyco3-1.7.0a7/c/py3/xor-kernels.h +88 -0
  35. psyco3-1.7.0a7/pyproject.toml +39 -0
  36. psyco3-1.7.0a7/setup.cfg +4 -0
  37. psyco3-1.7.0a7/setup.py +121 -0
  38. psyco3-1.7.0a7/src/psyco/__init__.py +59 -0
  39. psyco3-1.7.0a7/src/psyco/_byte_loop.py +149 -0
  40. psyco3-1.7.0a7/src/psyco/_frame_mode.py +36 -0
  41. psyco3-1.7.0a7/src/psyco/_loops.py +61 -0
  42. psyco3-1.7.0a7/src/psyco/_support.py +29 -0
  43. psyco3-1.7.0a7/src/psyco/compiler.py +357 -0
  44. psyco3-1.7.0a7/src/psyco/fields.py +145 -0
  45. psyco3-1.7.0a7/src/psyco/frame.py +74 -0
  46. psyco3-1.7.0a7/src/psyco/portable_api.py +338 -0
  47. psyco3-1.7.0a7/src/psyco3.egg-info/PKG-INFO +398 -0
  48. psyco3-1.7.0a7/src/psyco3.egg-info/SOURCES.txt +50 -0
  49. psyco3-1.7.0a7/src/psyco3.egg-info/dependency_links.txt +1 -0
  50. psyco3-1.7.0a7/src/psyco3.egg-info/top_level.txt +1 -0
  51. psyco3-1.7.0a7/tests/test_port.py +2916 -0
  52. psyco3-1.7.0a7/tools/pgo_train.py +227 -0
@@ -0,0 +1,9 @@
1
+ Psyco is distributed under the MIT License.
2
+
3
+ Copyright (c) 2001-2003 Armin Rigo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,3 @@
1
+ include c/py3/*.c c/py3/*.h c/ivm/asm-fragment.h
2
+ include tests/test_port.py benchmarks/native_loops.py benchmarks/compare_cinderx.py benchmarks/simd.py benchmarks/data_loops.py benchmarks/automatic.py benchmarks/call_overhead.py tools/pgo_train.py
3
+ prune test
@@ -0,0 +1,398 @@
1
+ Metadata-Version: 2.4
2
+ Name: psyco3
3
+ Version: 1.7.0a7
4
+ Summary: A specializing compiler for CPython on Linux
5
+ Author: Armin Rigo, Per Øyvind Karlsen
6
+ License-Expression: MIT
7
+ Project-URL: Repository, https://github.com/proyvind/psyco
8
+ Project-URL: Upstream, https://psyco.sourceforge.net/
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Operating System :: POSIX :: Linux
12
+ Classifier: Programming Language :: C
13
+ Classifier: Programming Language :: Python :: 3 :: Only
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Programming Language :: Python :: 3.14
19
+ Classifier: Programming Language :: Python :: 3.15
20
+ Classifier: Programming Language :: Python :: Implementation :: CPython
21
+ Classifier: Topic :: Software Development :: Compilers
22
+ Requires-Python: <3.16,>=3.10
23
+ Description-Content-Type: text/markdown
24
+ License-File: COPYING.txt
25
+ Dynamic: license-file
26
+
27
+ # Psyco 3
28
+
29
+ Psyco specializes selected Python functions to native machine code at runtime.
30
+ This alpha supports **CPython 3.10 through 3.15 on Linux**. It has no runtime
31
+ dependencies outside the Python standard library.
32
+
33
+ ## Installation
34
+
35
+ The distribution is named `psyco3` and the Python import is `psyco`. Once the
36
+ alpha is published on PyPI, install it with:
37
+
38
+ ```sh
39
+ python -m pip install --pre psyco3
40
+ ```
41
+
42
+ To install directly from a checkout:
43
+
44
+ ```sh
45
+ python -m pip install .
46
+ ```
47
+
48
+ To install from a distribution file, pass its path to `python -m pip install`.
49
+ A compatible wheel includes the compiled extension. Building from source
50
+ requires the matching CPython development headers and a GNU C11 compiler with
51
+ GCC-style assembler and integer-overflow builtins.
52
+
53
+ On standard CPython 3.15, native GCC builds for x86-64 and AArch64 use
54
+ profile-guided optimization. The build runs the correctness suite and a small
55
+ tree traversal, instruction interpreter and byte reductions at several vector
56
+ widths on an instrumented copy of the extension, then builds the
57
+ wheel with the collected profile. Set `PSYCO_PGO=0` for a single-pass build
58
+ or `PSYCO_PGO=1` to require the profiled build on these targets.
59
+
60
+ The Linux backends target 32-bit x86 (i686), x86-64, little-endian AArch64,
61
+ ARMv6, ARMv7, SPARC32plus, SPARC64, MIPS o32 and MIPS64 n64. Both MIPS
62
+ ABIs support little-endian (`mipsel`, `mips64el`) and big-endian (`mips`,
63
+ `mips64`) systems. On MIPS, install the source distribution with
64
+ `python -m pip install --no-binary=psyco3 --pre psyco3` after publication,
65
+ or pass the local source archive to pip. The compiler uses the ABI and byte
66
+ order of the running CPython. On x86, a 32-bit CPython uses the i686 wheel
67
+ even on a 64-bit kernel.
68
+
69
+ Use the `mipsel` wheel directory for 32-bit little-endian o32 and
70
+ `mips64el` for 64-bit little-endian n64. Keep these wheels separate from
71
+ big-endian builds because the generic Linux wheel tags omit MIPS byte order. Free-threaded CPython
72
+ 3.13–3.15 uses a separate wheel for each minor release (for example,
73
+ `cp315-cp315t`). With the matching directory supplied to `--find-links`,
74
+ pip selects the ABI for the running interpreter automatically.
75
+
76
+ ## Use
77
+
78
+ ```python
79
+ import psyco
80
+
81
+ def total(n):
82
+ result = 0
83
+ while n > 0:
84
+ result += n
85
+ n -= 1
86
+ return result
87
+
88
+ fast_total = psyco.proxy(total)
89
+ assert fast_total(100) == 5050
90
+ ```
91
+
92
+ `psyco.proxy(f)` creates a specialized callable. `psyco.bind(f)` enables
93
+ specialization for existing references to a function. `psyco.full()` enables
94
+ automatic selection. `psyco.profile(threshold=8)` normally waits for repeated
95
+ calls. On standard CPython 3.15 it can select grouped rows and filtered byte
96
+ buffers on their first large input. A matching grouping loop over a row
97
+ iterator such as `csv.reader` can also enter on its first call on this backend.
98
+
99
+ For a one-shot analysis, use `psyco.profile(module=__name__)` before loading
100
+ the data. Only functions defined in that module participate in automatic
101
+ selection. Imported helpers still run normally. Use `module=globals()` for
102
+ an isolated execution namespace, or pass a loaded module object. The same
103
+ option is available on `psyco.full()`. Changing the scope takes effect on
104
+ subsequent calls. Explicit bindings and proxies stay active across scopes.
105
+ On the public call adapter, define filtered-byte or grouped-row functions
106
+ before enabling a module scope to select those recognized templates on
107
+ their first invocation. Other functions discovered by the profiler can
108
+ specialize on subsequent calls. Use `psyco.proxy(f)` for explicit selection.
109
+
110
+ `psyco._psyco.native_stats()` reports native compilations and calls.
111
+
112
+ Psyco handles selected integer operations, comparisons, branches, loops and
113
+ straight-line floating-point arithmetic. A loop that adds or subtracts each
114
+ item of an exact tuple of integers can run in a checked native loop when the
115
+ accumulator starts at an integer literal. Other bytecode, unsupported operand
116
+ types and integer overflow fall back to CPython. On regular CPython 3.15,
117
+ Psyco hooks the frame evaluator. Repeated positional calls can enter numeric
118
+ programs directly. On x86-64 and AArch64, short unary arithmetic expressions
119
+ keep intermediate integers or doubles in registers. It specializes reads of plain instance fields,
120
+ short-circuit boolean field expressions, simple flag assignments and indexed
121
+ lookups in lists or tuples held by a global object's field. For methods that
122
+ combine calls, field updates, integer arithmetic, indexing and branches, the
123
+ object backend compiles a direct-threaded program of native C operations.
124
+ It caches ordinary fields and methods by type and fuses common operations,
125
+ including calls to simple field methods and loops that follow object links.
126
+ On a guard miss CPython resumes at the original bytecode position, with earlier
127
+ side effects preserved. A method lookup followed by a return to CPython is
128
+ counted separately from a completed call. On earlier supported versions and on
129
+ free-threaded builds it uses a function-call adapter. Automatic discovery in
130
+ the adapter sees module-level functions on the thread that enabled profiling.
131
+ Recursive specialization depth, compact object layouts and historical
132
+ profiler tuning options are unavailable in this port.
133
+
134
+ On standard CPython 3.15, eligible callers can inline a no-argument method that
135
+ returns two to four fields and unpack its result directly. For example,
136
+ `x, y = point.coords()` can read the fields of `return self.x, self.y`
137
+ without creating a tuple. This supports ordinary instance fields and Python
138
+ `__slots__`, with checks for the receiver type, shadowed methods and changes
139
+ to the method or descriptors. Returning the tuple to other code retains its
140
+ ordinary Python behavior. A caller such as `return rect.area() * scale` can
141
+ also inline `return self.width * self.height`. Both operations may add,
142
+ subtract or multiply, with a positional argument or literal on the right in
143
+ the caller. Two exact compact integers or two exact floats can stay unboxed
144
+ across the call. The integer path checks for overflow and the floating-point
145
+ path rounds each operation separately. Automatic selection skips functions
146
+ with cell or free variables before invoking the compiler. Straightforward
147
+ field reads and two-field arithmetic can run without importing `dis`.
148
+
149
+ Adjacent object arithmetic operations such as
150
+ `total + (x * y)` can keep the intermediate product unboxed for exact compact
151
+ integers or floats. Automatic selection periodically retries unsuccessful plans
152
+ when later inputs may fit, including calls from another object plan. Explicit
153
+ bindings remain eager. An object loop over an exact list or tuple uses
154
+ CPython's virtual iterator. A branch that builds a dictionary or formats a
155
+ value can resume in CPython even after earlier iterations updated an object.
156
+
157
+ For the four-argument loop below, the native path checks the exact tuple,
158
+ integer indices and scale at entry. It validates the entire index interval
159
+ once, including negative indices and intervals crossing zero. For exact
160
+ integers it sums the items and multiplies once at the end. With an exact
161
+ float scale it preserves the order and rounding of each multiply and add.
162
+ The same reduction supports `for item in values: total += item * scale` on an
163
+ exact tuple. The byte-buffer path continues to handle bytes and memoryviews.
164
+
165
+ ```python
166
+ def scaled_sum(values, i, stop, scale):
167
+ total = 0
168
+ while i < stop:
169
+ total += values[i] * scale
170
+ i += 1
171
+ return total
172
+ ```
173
+
174
+ On standard CPython 3.15, sums of field products such as
175
+ `a.x * b.x + a.y * b.y` can keep the products unboxed. The evaluator checks
176
+ the two receiver layouts once for the expression and checks each field value.
177
+ It can also keep exact float arithmetic and comparisons in an object loop
178
+ with ordinary Python fallback for customized operators or descriptors.
179
+
180
+ Straight-line expressions such as `x * 7 - 1` can keep both an integer
181
+ and a float variant. The float variant accepts exact floats and promotes
182
+ integer literals only when every arithmetic operation has a float operand
183
+ and the literals are exactly representable within the 53-bit limit.
184
+
185
+ ## Row aggregation and filtered byte buffers
186
+
187
+ The following two loop bodies can enter native code through `psyco.proxy`.
188
+ The compiler checks their complete bytecode on the running CPython version.
189
+
190
+ ```python
191
+ def group_rows(rows, wanted):
192
+ totals = {}
193
+ for category, status, amount in rows:
194
+ if status == wanted:
195
+ totals[category] = totals.get(category, 0) + int(amount)
196
+ return totals
197
+
198
+
199
+ def filter_bytes(data, minimum, scale):
200
+ total = 0
201
+ for b in data:
202
+ if b >= minimum:
203
+ total += b * scale
204
+ return total
205
+ ```
206
+
207
+ Grouping accepts materialized lists and tuples on GIL builds. On standard
208
+ CPython 3.15, `psyco.full()` or `psyco.proxy(group_rows)` can also process a
209
+ `csv.reader` directly. The loop keeps a running dictionary and the current
210
+ row's local variables. Short ASCII amounts can contain a sign, surrounding
211
+ whitespace and underscores between digits. Fresh, unshared CSV row lists
212
+ transfer ownership of their three string fields to the frame locals. If a
213
+ value needs ordinary Python conversion, or an iterator callback requests
214
+ the caller's frame, CPython continues with the
215
+ same iterator and running totals. On the public-API adapter, streaming uses
216
+ Python. GIL builds of that adapter can specialize batches under 65,536 rows.
217
+
218
+ For byte reductions, the compiler recognizes the iteration, up to two
219
+ predicates, and addition or subtraction from a zero seed. Predicates can
220
+ compare or test a masked byte. The update can sum selected values or count
221
+ matches with a constant or argument as the increment. Bounds, masks and
222
+ scales can be integer arguments or literals. For example, both `if low <= b < high:` and
223
+ `if b >= low and b < high:` can guard `total -= (b & mask) * scale`.
224
+ The native path accepts exact bytes and contiguous unsigned-byte views,
225
+ checks the operands once per call, and accumulates in bounded chunks. The
226
+ unfiltered sum uses the existing CPU-dispatched kernel. Unsupported types
227
+ and layouts use Python. On the public-API adapter, filtered and weighted
228
+ zero-seed loops over exact immutable bytes or contiguous unsigned-byte views
229
+ of those bytes can process inputs of 4 MiB or more. They combine
230
+ 1 MiB native results as Python integers, checking monitoring between batches.
231
+ A native chunk that overflows can replay the pure loop in Python. On
232
+ standard CPython 3.15, profiled selection can try a short loop on its first large byte buffer (4,096 bytes) or materialized input
233
+ (128 rows). Use `psyco.proxy` to select explicitly on all supported versions.
234
+
235
+ On the 3.15 frame backend, an arithmetic operation over two inline instance
236
+ fields (`p.x * p.y`, for example) can consume both numbers while their owner
237
+ is live. The cached type, storage and exact numeric operands are checked
238
+ before using borrowed references. Descriptors and overloaded operators follow
239
+ ordinary Python lookup and ownership rules.
240
+
241
+ Run `python benchmarks/data_loops.py 100000 9` for fresh-process timing and
242
+ peak resident memory, including materialized rows, batches and streaming.
243
+ Add `--formatted` for signed decimal fields with whitespace and separators.
244
+ Run `benchmarks/loop_variants.py --engine python` and again with
245
+ `--engine proxy` to compare twenty byte loops. Each result includes a
246
+ CPython result check, the number of timed calls with native completions,
247
+ and the number of completions (which can include multiple chunks per call).
248
+ Use `--engine full` for automatic selection or `--case NAME` to isolate a loop.
249
+ Use `--engine cinderx` to time the same functions after CinderX confirms
250
+ explicit compilation.
251
+
252
+ ## Runtime CPU dispatch
253
+
254
+ For an exact `bytes` object, Psyco specializes loops of the form
255
+ `for value in data: total += value` or `total += value.bit_count()`. Both
256
+ also support subtraction and an integer literal as the initial accumulator.
257
+ Short inputs and the final partial vector use bounded loads. Integer overflow,
258
+ custom iterators and overridden methods retain ordinary Python behavior.
259
+
260
+ | Target | Byte sum | Byte population count |
261
+ | --- | --- | --- |
262
+ | i686 and x86-64 | SSE2, AVX2, AVX-512F + BW | POPCNT, AVX2, AVX-512F + VPOPCNTDQ |
263
+ | AArch64 | Advanced SIMD (NEON), SVE | Advanced SIMD (NEON), SVE, SVE2 |
264
+ | Other supported Linux targets | Baseline | Baseline |
265
+
266
+ The extension selects kernels using x86 CPUID and the OS-enabled register
267
+ state in XCR0, or Linux hardware capabilities on AArch64. The same wheel runs
268
+ on older CPUs of its ABI. Standard CPython 3.15 also sums tuples of cached
269
+ small integers using AVX2, AVX-512F or AArch64 NEON. Other tuple entries use
270
+ the existing checked path.
271
+
272
+ `psyco.cpu_features(4096)` reports the usable features relevant to these
273
+ operations and the kernels selected for that many bytes or tuple elements.
274
+ To benchmark narrower implementations, set `PSYCO_SIMD_MAX_BITS` to
275
+ `0`, `128`, `256` or `512` before starting Python. The ceiling applies
276
+ to explicitly dispatched vectors. Baseline compiler instructions and scalar
277
+ POPCNT remain available. An explicit ceiling selects fixed-width kernels on
278
+ AArch64, since a thread's SVE vector length can change. Leave the variable
279
+ unset for automatic dispatch. Run `python benchmarks/simd.py` to compare
280
+ input sizes and record the selected kernels and timings.
281
+
282
+ The byte kernels also handle unsigned, one-dimensional contiguous memoryviews
283
+ over `bytes`, including misaligned slices. GIL builds additionally handle
284
+ views over `bytearray`. A loop of the form `for b in view: total ^= b` uses
285
+ SSE2, AVX2, AVX-512F, NEON or SVE when available. Strided views, other
286
+ formats and mutable backing on free-threaded Python retain Python iteration.
287
+
288
+ For loops that add or subtract `b * b` for each unsigned byte, Psyco can
289
+ compute a sum of squares over the same buffers. On x86 it selects AVX2 for
290
+ chunks of at least 128 bytes. From 512 bytes it can use the 512-bit
291
+ unsigned-byte dot product `VPDPBUUD` with AVX10.2 (or AVX10.1 with
292
+ `AVX10_V1_AUX`) and OS-enabled ZMM state. AArch64 can use SVE for the
293
+ same operation. Other targets use a portable kernel.
294
+ `psyco.cpu_features(n)["byte_sum_squares"]` reports the selection
295
+ for a chunk of length `n`. Use `python benchmarks/simd.py --group squares`
296
+ and `PSYCO_SIMD_MAX_BITS` to compare widths on the same inputs.
297
+
298
+ Psyco also recognizes the two bit-at-a-time checksum loops in
299
+ `benchmarks/simd.py`. They initialize and finalize with `0xffffffff`,
300
+ XOR each byte into the state, and perform eight right-shift steps using
301
+ a local countdown. The reflected polynomial selects IEEE CRC-32
302
+ (`0xedb88320`) or CRC-32C/Castagnoli (`0x82f63b78`). On x86, IEEE CRC-32
303
+ uses PCLMULQDQ folding from 128 bytes. CRC-32C uses SSE4.2 CRC32 and
304
+ can switch to PCLMULQDQ from 512 bytes.
305
+ AArch64 can use its scalar CRC extension for both. Otherwise the generated
306
+ plan uses a portable table. The compiler verifies the complete loop before
307
+ substituting a kernel. `psyco.cpu_features(n)` reports `crc32` and `crc32c`.
308
+ Run `python benchmarks/simd.py --group crc` to measure the loops, or add
309
+ `--engine zlib` for the standard library's native IEEE CRC-32 comparison.
310
+
311
+ For chunks of at least 512 bytes on AArch64, SVE2 population count uses
312
+ widening pairwise accumulation and one horizontal sum per chunk. SVE handles
313
+ byte sum of squares with unsigned dot products. Both adapt to the running
314
+ thread's vector length and use predicated loads for the final partial vector.
315
+
316
+ Integer code specializes `x.bit_count()`, `x.bit_length()`, the masks
317
+ `x & (x - 1)` and `x & -x`, and variable left and right shifts. On x86-64
318
+ the compiler can emit POPCNT, LZCNT, BMI1 BLSR/BLSI and BMI2 SHLX/SARX
319
+ independently. On AArch64 it uses CLZ and, where available, NEON CNT for
320
+ population count. Signed word overflow, negative or oversized shift counts,
321
+ large Python integers and custom methods can return to CPython.
322
+ Run `python benchmarks/simd.py --group bitops` to time these workloads.
323
+ For a same-wheel comparison, set `PSYCO_DISABLE_WORD_ISA=1` before starting
324
+ Python to use the baseline scalar instructions. Byte-kernel selection remains
325
+ controlled by `PSYCO_SIMD_MAX_BITS`.
326
+
327
+ On x86-64, the CPython 3.15 GIL backend uses six integer temporaries for
328
+ straight-line expressions in one argument. With Intel APX and OS-enabled
329
+ extended register state it can use up to 16, enough for the current limit
330
+ of 32 instructions per scalar expression. This keeps deeper additions,
331
+ subtractions and multiplications in registers. Where the CPU also advertises
332
+ APX NDD, `x + constant`, `x - constant`, `x * constant` and their `x op x`
333
+ forms can write directly to a distinct result register. Each arithmetic
334
+ operation still checks signed overflow before continuing.
335
+ `psyco.cpu_features()` reports the active limit in `scalar_int_registers`
336
+ (zero on backends without scalar leaves), and `scalar_int_ndd` reports
337
+ whether three-operand emission is enabled. `PSYCO_DISABLE_WORD_ISA=1`
338
+ also selects the ordinary x86-64 integer path.
339
+ Run `python benchmarks/simd.py --group scalar` to time a simple addition
340
+ and two nested integer expressions on the host CPU.
341
+
342
+ ## Building distributions
343
+
344
+ From a clean checkout with a supported Linux interpreter:
345
+
346
+ ```sh
347
+ python -m pip install build twine auditwheel patchelf
348
+ python -m build
349
+ auditwheel repair --wheel-dir wheelhouse dist/*.whl
350
+ python -m twine check --strict dist/*.tar.gz wheelhouse/*.whl
351
+ ```
352
+
353
+ The build creates a source archive and then compiles a wheel from that archive.
354
+ For a release, use the source archive and the repaired wheels in `wheelhouse/`.
355
+ Each wheel is specific to a CPython ABI and architecture. Build additional
356
+ wheels from the same source archive on the desired targets. To test an
357
+ installed distribution, run `python tests/test_port.py` from the checkout
358
+ with the interpreter that installed it.
359
+
360
+ GitHub Actions checks the source distribution and builds and tests manylinux
361
+ wheels for x86-64 and AArch64. Other supported Linux architectures can build
362
+ from the source distribution. The `publish-pypi.yml` workflow publishes only
363
+ from matching `v<version>` tags pushed to this repository, using PyPI Trusted
364
+ Publishing and the `pypi` environment. Pull requests and manual checks build
365
+ artifacts without uploading to PyPI.
366
+
367
+ To inspect Richards coverage on standard CPython 3.15, install Psyco and
368
+ `pyperformance==1.14.0` and run
369
+ `python benchmarks/compare_cinderx.py --coverage coverage.csv`. The CSV compares
370
+ ordinary Python call counts with completed and partial Psyco calls per function.
371
+
372
+ To measure automatic selection, install `pyperformance==1.14.0` and run
373
+ `python benchmarks/automatic.py --cpu 2` with a CPU in your affinity mask.
374
+ Use `--engine python psyco scoped` to compare ordinary CPython, unrestricted
375
+ `psyco.full()` and `psyco.profile()` restricted to each benchmark module.
376
+ The default selection covers 25 workloads. Each runs with CPython and
377
+ with `psyco.full()` in separate pinned processes. JSON lines contain the raw
378
+ worker samples. Use `--engine python psyco cinderx` with CinderX installed to
379
+ include its automatic JIT on the same workloads. On standard CPython 3.15,
380
+ a separate `--diagnostics --engine psyco` run counts compilation attempts,
381
+ compilation wall time, completed calls (including inlined calls), cached
382
+ rejections, delayed retries, numeric and field guard misses, and the original
383
+ opcode at object side exits, including the operator for binary instructions. These counters cover worker warmup and samples,
384
+ including benchmark setup executed within them. Use separate runs with the
385
+ counters disabled for timings. `python benchmarks/call_overhead.py --cpu 2` also measures
386
+ startup, short scripts including an invoice calculation, warm method calls, alternating numeric types and the
387
+ scaled tuple loop. To compare revisions, supply
388
+ `--engine python old new` and set `BENCH_OLD` and `BENCH_NEW` to isolated
389
+ Psyco installation directories.
390
+
391
+ ## History
392
+
393
+ The [development branch](https://github.com/proyvind/psyco/tree/devel)
394
+ incorporates the upstream revision history. The
395
+ [earlier source tree](https://github.com/proyvind/psyco/tree/c7db25b81e4cb278ab52ef9a216af33da776d084)
396
+ contains the installation instructions and sources for Python 2 and CPython
397
+ 3.0–3.9. The original sources are also preserved in the
398
+ [Bitbucket archive](https://bitbucket-archive.softwareheritage.org/projects/ar/arigo/psyco.html).