pystachy 0.2.0__tar.gz → 0.3.0__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 (172) hide show
  1. {pystachy-0.2.0 → pystachy-0.3.0}/PKG-INFO +30 -7
  2. {pystachy-0.2.0 → pystachy-0.3.0}/README.md +29 -6
  3. {pystachy-0.2.0 → pystachy-0.3.0}/THIRD_PARTY_NOTICES +66 -8
  4. pystachy-0.3.0/VERSION +1 -0
  5. pystachy-0.3.0/lib/_pystachy_cache.py +20 -0
  6. pystachy-0.3.0/lib/_pystachy_ctypes.py +8 -0
  7. pystachy-0.3.0/lib/ctypes.py +89 -0
  8. {pystachy-0.2.0 → pystachy-0.3.0}/lib/mpz.py +3 -3
  9. {pystachy-0.2.0 → pystachy-0.3.0}/lib/pyobj.py +130 -1
  10. {pystachy-0.2.0 → pystachy-0.3.0}/pyembed.c +146 -0
  11. {pystachy-0.2.0 → pystachy-0.3.0}/pystachy.egg-info/PKG-INFO +30 -7
  12. {pystachy-0.2.0 → pystachy-0.3.0}/pystachy.egg-info/SOURCES.txt +9 -0
  13. {pystachy-0.2.0 → pystachy-0.3.0}/pystachy_toolchain.py +35 -7
  14. {pystachy-0.2.0 → pystachy-0.3.0}/runtime.c +551 -68
  15. {pystachy-0.2.0 → pystachy-0.3.0}/runtime.py +191 -12
  16. {pystachy-0.2.0 → pystachy-0.3.0}/src/pystachy_compiler/analysis.py +22 -1
  17. {pystachy-0.2.0 → pystachy-0.3.0}/src/pystachy_compiler/builtins.py +56 -2
  18. pystachy-0.3.0/src/pystachy_compiler/cache_toolchain.py +338 -0
  19. pystachy-0.3.0/src/pystachy_compiler/cached_run.py +308 -0
  20. pystachy-0.3.0/src/pystachy_compiler/callbacks.py +209 -0
  21. {pystachy-0.2.0 → pystachy-0.3.0}/src/pystachy_compiler/calls.py +19 -0
  22. {pystachy-0.2.0 → pystachy-0.3.0}/src/pystachy_compiler/containers.py +6 -2
  23. {pystachy-0.2.0 → pystachy-0.3.0}/src/pystachy_compiler/conversions.py +2 -4
  24. pystachy-0.3.0/src/pystachy_compiler/ctypes_schema.py +274 -0
  25. {pystachy-0.2.0 → pystachy-0.3.0}/src/pystachy_compiler/declarations.py +15 -6
  26. {pystachy-0.2.0 → pystachy-0.3.0}/src/pystachy_compiler/driver.py +59 -9
  27. {pystachy-0.2.0 → pystachy-0.3.0}/src/pystachy_compiler/dynamic.py +730 -55
  28. {pystachy-0.2.0 → pystachy-0.3.0}/src/pystachy_compiler/emission.py +33 -1
  29. {pystachy-0.2.0 → pystachy-0.3.0}/src/pystachy_compiler/exceptions.py +11 -2
  30. {pystachy-0.2.0 → pystachy-0.3.0}/src/pystachy_compiler/expressions.py +78 -10
  31. {pystachy-0.2.0 → pystachy-0.3.0}/src/pystachy_compiler/functions.py +3 -2
  32. {pystachy-0.2.0 → pystachy-0.3.0}/src/pystachy_compiler/gen.py +49 -3
  33. {pystachy-0.2.0 → pystachy-0.3.0}/src/pystachy_compiler/ir.py +9 -3
  34. {pystachy-0.2.0 → pystachy-0.3.0}/src/pystachy_compiler/ircheck.py +20 -3
  35. {pystachy-0.2.0 → pystachy-0.3.0}/src/pystachy_compiler/loader.py +13 -4
  36. {pystachy-0.2.0 → pystachy-0.3.0}/src/pystachy_compiler/lower_module.py +24 -9
  37. {pystachy-0.2.0 → pystachy-0.3.0}/src/pystachy_compiler/lowering.py +35 -1
  38. {pystachy-0.2.0 → pystachy-0.3.0}/src/pystachy_compiler/optimizations.py +119 -16
  39. {pystachy-0.2.0 → pystachy-0.3.0}/src/pystachy_compiler/program.py +5 -0
  40. pystachy-0.3.0/src/pystachy_compiler/program_cache.py +757 -0
  41. {pystachy-0.2.0 → pystachy-0.3.0}/src/pystachy_compiler/reflection.py +161 -2
  42. pystachy-0.3.0/src/pystachy_compiler/source_lines.py +166 -0
  43. {pystachy-0.2.0 → pystachy-0.3.0}/src/pystachy_compiler/specs.py +21 -10
  44. {pystachy-0.2.0 → pystachy-0.3.0}/src/pystachy_compiler/statements.py +5 -3
  45. {pystachy-0.2.0 → pystachy-0.3.0}/src/pystachy_compiler/union_proof.py +4 -0
  46. {pystachy-0.2.0 → pystachy-0.3.0}/src/pystachy_compiler/utils.py +55 -14
  47. {pystachy-0.2.0 → pystachy-0.3.0}/src/pystachy_compiler/variables.py +7 -5
  48. pystachy-0.2.0/VERSION +0 -1
  49. {pystachy-0.2.0 → pystachy-0.3.0}/LICENSE +0 -0
  50. {pystachy-0.2.0 → pystachy-0.3.0}/lib/_argparse_help.py +0 -0
  51. {pystachy-0.2.0 → pystachy-0.3.0}/lib/_markupbase.py +0 -0
  52. {pystachy-0.2.0 → pystachy-0.3.0}/lib/_pyrandom.py +0 -0
  53. {pystachy-0.2.0 → pystachy-0.3.0}/lib/_pystachy__io.py +0 -0
  54. {pystachy-0.2.0 → pystachy-0.3.0}/lib/_pystachy_abc.py +0 -0
  55. {pystachy-0.2.0 → pystachy-0.3.0}/lib/_pystachy_atexit.py +0 -0
  56. {pystachy-0.2.0 → pystachy-0.3.0}/lib/_pystachy_bfile.py +0 -0
  57. {pystachy-0.2.0 → pystachy-0.3.0}/lib/_pystachy_binascii.py +0 -0
  58. {pystachy-0.2.0 → pystachy-0.3.0}/lib/_pystachy_bytescan.py +0 -0
  59. {pystachy-0.2.0 → pystachy-0.3.0}/lib/_pystachy_codecs.py +0 -0
  60. {pystachy-0.2.0 → pystachy-0.3.0}/lib/_pystachy_copy.py +0 -0
  61. {pystachy-0.2.0 → pystachy-0.3.0}/lib/_pystachy_iterators.py +0 -0
  62. {pystachy-0.2.0 → pystachy-0.3.0}/lib/_pystachy_itertools.py +0 -0
  63. {pystachy-0.2.0 → pystachy-0.3.0}/lib/_pystachy_json_any.py +0 -0
  64. {pystachy-0.2.0 → pystachy-0.3.0}/lib/_pystachy_json_int.py +0 -0
  65. {pystachy-0.2.0 → pystachy-0.3.0}/lib/_pystachy_mappingproxy.py +0 -0
  66. {pystachy-0.2.0 → pystachy-0.3.0}/lib/_pystachy_object.py +0 -0
  67. {pystachy-0.2.0 → pystachy-0.3.0}/lib/_pystachy_percent.py +0 -0
  68. {pystachy-0.2.0 → pystachy-0.3.0}/lib/_pystachy_range.py +0 -0
  69. {pystachy-0.2.0 → pystachy-0.3.0}/lib/_pystachy_re_specialized.py +0 -0
  70. {pystachy-0.2.0 → pystachy-0.3.0}/lib/_pystachy_string.py +0 -0
  71. {pystachy-0.2.0 → pystachy-0.3.0}/lib/_pystachy_struct.py +0 -0
  72. {pystachy-0.2.0 → pystachy-0.3.0}/lib/_pystachy_thread.py +0 -0
  73. {pystachy-0.2.0 → pystachy-0.3.0}/lib/_pystachy_time.py +0 -0
  74. {pystachy-0.2.0 → pystachy-0.3.0}/lib/_pystachy_types.py +0 -0
  75. {pystachy-0.2.0 → pystachy-0.3.0}/lib/_pystachy_unicodedata.py +0 -0
  76. {pystachy-0.2.0 → pystachy-0.3.0}/lib/_pystachy_unicodedata_db.py +0 -0
  77. {pystachy-0.2.0 → pystachy-0.3.0}/lib/_pystachy_unicodedata_names.py +0 -0
  78. {pystachy-0.2.0 → pystachy-0.3.0}/lib/_pystachy_weakref.py +0 -0
  79. {pystachy-0.2.0 → pystachy-0.3.0}/lib/_weakrefset.py +0 -0
  80. {pystachy-0.2.0 → pystachy-0.3.0}/lib/argparse.py +0 -0
  81. {pystachy-0.2.0 → pystachy-0.3.0}/lib/bisect.py +0 -0
  82. {pystachy-0.2.0 → pystachy-0.3.0}/lib/codecs.py +0 -0
  83. {pystachy-0.2.0 → pystachy-0.3.0}/lib/collections/__init__.py +0 -0
  84. {pystachy-0.2.0 → pystachy-0.3.0}/lib/colorsys.py +0 -0
  85. {pystachy-0.2.0 → pystachy-0.3.0}/lib/contextlib.py +0 -0
  86. {pystachy-0.2.0 → pystachy-0.3.0}/lib/copy.py +0 -0
  87. {pystachy-0.2.0 → pystachy-0.3.0}/lib/csv.py +0 -0
  88. {pystachy-0.2.0 → pystachy-0.3.0}/lib/curses/__init__.py +0 -0
  89. {pystachy-0.2.0 → pystachy-0.3.0}/lib/curses/ascii.py +0 -0
  90. {pystachy-0.2.0 → pystachy-0.3.0}/lib/datetime.py +0 -0
  91. {pystachy-0.2.0 → pystachy-0.3.0}/lib/difflib.py +0 -0
  92. {pystachy-0.2.0 → pystachy-0.3.0}/lib/enum.py +0 -0
  93. {pystachy-0.2.0 → pystachy-0.3.0}/lib/fnmatch.py +0 -0
  94. {pystachy-0.2.0 → pystachy-0.3.0}/lib/functools.py +0 -0
  95. {pystachy-0.2.0 → pystachy-0.3.0}/lib/genericpath.py +0 -0
  96. {pystachy-0.2.0 → pystachy-0.3.0}/lib/getopt.py +0 -0
  97. {pystachy-0.2.0 → pystachy-0.3.0}/lib/gettext.py +0 -0
  98. {pystachy-0.2.0 → pystachy-0.3.0}/lib/glob.py +0 -0
  99. {pystachy-0.2.0 → pystachy-0.3.0}/lib/heapq.py +0 -0
  100. {pystachy-0.2.0 → pystachy-0.3.0}/lib/html/__init__.py +0 -0
  101. {pystachy-0.2.0 → pystachy-0.3.0}/lib/html/entities.py +0 -0
  102. {pystachy-0.2.0 → pystachy-0.3.0}/lib/html/parser.py +0 -0
  103. {pystachy-0.2.0 → pystachy-0.3.0}/lib/io.py +0 -0
  104. {pystachy-0.2.0 → pystachy-0.3.0}/lib/json.py +0 -0
  105. {pystachy-0.2.0 → pystachy-0.3.0}/lib/keyword.py +0 -0
  106. {pystachy-0.2.0 → pystachy-0.3.0}/lib/logging/__init__.py +0 -0
  107. {pystachy-0.2.0 → pystachy-0.3.0}/lib/operator.py +0 -0
  108. {pystachy-0.2.0 → pystachy-0.3.0}/lib/pathlib.py +0 -0
  109. {pystachy-0.2.0 → pystachy-0.3.0}/lib/posixpath.py +0 -0
  110. {pystachy-0.2.0 → pystachy-0.3.0}/lib/random.py +0 -0
  111. {pystachy-0.2.0 → pystachy-0.3.0}/lib/re/__init__.py +0 -0
  112. {pystachy-0.2.0 → pystachy-0.3.0}/lib/re/_constants.py +0 -0
  113. {pystachy-0.2.0 → pystachy-0.3.0}/lib/re/_sre.py +0 -0
  114. {pystachy-0.2.0 → pystachy-0.3.0}/lib/re/_unicode.py +0 -0
  115. {pystachy-0.2.0 → pystachy-0.3.0}/lib/shlex.py +0 -0
  116. {pystachy-0.2.0 → pystachy-0.3.0}/lib/shutil.py +0 -0
  117. {pystachy-0.2.0 → pystachy-0.3.0}/lib/stat.py +0 -0
  118. {pystachy-0.2.0 → pystachy-0.3.0}/lib/statistics.py +0 -0
  119. {pystachy-0.2.0 → pystachy-0.3.0}/lib/string.py +0 -0
  120. {pystachy-0.2.0 → pystachy-0.3.0}/lib/struct.py +0 -0
  121. {pystachy-0.2.0 → pystachy-0.3.0}/lib/textwrap.py +0 -0
  122. {pystachy-0.2.0 → pystachy-0.3.0}/lib/this.py +0 -0
  123. {pystachy-0.2.0 → pystachy-0.3.0}/lib/threading.py +0 -0
  124. {pystachy-0.2.0 → pystachy-0.3.0}/lib/token.py +0 -0
  125. {pystachy-0.2.0 → pystachy-0.3.0}/lib/tomllib/__init__.py +0 -0
  126. {pystachy-0.2.0 → pystachy-0.3.0}/lib/tomllib/_parser.py +0 -0
  127. {pystachy-0.2.0 → pystachy-0.3.0}/lib/tomllib/_re.py +0 -0
  128. {pystachy-0.2.0 → pystachy-0.3.0}/lib/tomllib/_types.py +0 -0
  129. {pystachy-0.2.0 → pystachy-0.3.0}/lib/traceback.py +0 -0
  130. {pystachy-0.2.0 → pystachy-0.3.0}/lib/types.py +0 -0
  131. {pystachy-0.2.0 → pystachy-0.3.0}/lib/urllib/__init__.py +0 -0
  132. {pystachy-0.2.0 → pystachy-0.3.0}/lib/urllib/parse.py +0 -0
  133. {pystachy-0.2.0 → pystachy-0.3.0}/lib/warnings.py +0 -0
  134. {pystachy-0.2.0 → pystachy-0.3.0}/lib/weakref.py +0 -0
  135. {pystachy-0.2.0 → pystachy-0.3.0}/mpz/mpz.c +0 -0
  136. {pystachy-0.2.0 → pystachy-0.3.0}/pyext.c +0 -0
  137. {pystachy-0.2.0 → pystachy-0.3.0}/pyproject.toml +0 -0
  138. {pystachy-0.2.0 → pystachy-0.3.0}/pystachy.egg-info/dependency_links.txt +0 -0
  139. {pystachy-0.2.0 → pystachy-0.3.0}/pystachy.egg-info/entry_points.txt +0 -0
  140. {pystachy-0.2.0 → pystachy-0.3.0}/pystachy.egg-info/top_level.txt +0 -0
  141. {pystachy-0.2.0 → pystachy-0.3.0}/pystachy.py +0 -0
  142. {pystachy-0.2.0 → pystachy-0.3.0}/pystachy_cli.py +0 -0
  143. {pystachy-0.2.0 → pystachy-0.3.0}/ryu/LICENSE-Boost +0 -0
  144. {pystachy-0.2.0 → pystachy-0.3.0}/ryu/common.h +0 -0
  145. {pystachy-0.2.0 → pystachy-0.3.0}/ryu/d2s.c +0 -0
  146. {pystachy-0.2.0 → pystachy-0.3.0}/ryu/d2s_intrinsics.h +0 -0
  147. {pystachy-0.2.0 → pystachy-0.3.0}/ryu/d2s_small_table.h +0 -0
  148. {pystachy-0.2.0 → pystachy-0.3.0}/ryu/digit_table.h +0 -0
  149. {pystachy-0.2.0 → pystachy-0.3.0}/ryu/ryu.h +0 -0
  150. {pystachy-0.2.0 → pystachy-0.3.0}/setup.cfg +0 -0
  151. {pystachy-0.2.0 → pystachy-0.3.0}/src/__init__.py +0 -0
  152. {pystachy-0.2.0 → pystachy-0.3.0}/src/pystachy_compiler/__init__.py +0 -0
  153. {pystachy-0.2.0 → pystachy-0.3.0}/src/pystachy_compiler/argparse_schema.py +0 -0
  154. {pystachy-0.2.0 → pystachy-0.3.0}/src/pystachy_compiler/bigints.py +0 -0
  155. {pystachy-0.2.0 → pystachy-0.3.0}/src/pystachy_compiler/diagnostics.py +0 -0
  156. {pystachy-0.2.0 → pystachy-0.3.0}/src/pystachy_compiler/flow.py +0 -0
  157. {pystachy-0.2.0 → pystachy-0.3.0}/src/pystachy_compiler/generators.py +0 -0
  158. {pystachy-0.2.0 → pystachy-0.3.0}/src/pystachy_compiler/lexer.py +0 -0
  159. {pystachy-0.2.0 → pystachy-0.3.0}/src/pystachy_compiler/llvm_abi.py +0 -0
  160. {pystachy-0.2.0 → pystachy-0.3.0}/src/pystachy_compiler/local_versions.py +0 -0
  161. {pystachy-0.2.0 → pystachy-0.3.0}/src/pystachy_compiler/memory_ir.py +0 -0
  162. {pystachy-0.2.0 → pystachy-0.3.0}/src/pystachy_compiler/module.py +0 -0
  163. {pystachy-0.2.0 → pystachy-0.3.0}/src/pystachy_compiler/names.py +0 -0
  164. {pystachy-0.2.0 → pystachy-0.3.0}/src/pystachy_compiler/parser.py +0 -0
  165. {pystachy-0.2.0 → pystachy-0.3.0}/src/pystachy_compiler/scalar_ir.py +0 -0
  166. {pystachy-0.2.0 → pystachy-0.3.0}/src/pystachy_compiler/scope.py +0 -0
  167. {pystachy-0.2.0 → pystachy-0.3.0}/src/pystachy_compiler/structs.py +0 -0
  168. {pystachy-0.2.0 → pystachy-0.3.0}/src/pystachy_compiler/syntax.py +0 -0
  169. {pystachy-0.2.0 → pystachy-0.3.0}/src/pystachy_compiler/templates.py +0 -0
  170. {pystachy-0.2.0 → pystachy-0.3.0}/src/pystachy_compiler/union_arithmetic.py +0 -0
  171. {pystachy-0.2.0 → pystachy-0.3.0}/src/pystachy_compiler/union_state.py +0 -0
  172. {pystachy-0.2.0 → pystachy-0.3.0}/src/pystachy_compiler/unions.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pystachy
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Summary: Compile a typed subset of Python to native code through LLVM
5
5
  License-Expression: MIT
6
6
  Project-URL: Source, https://github.com/den-run-ai/pystachy
@@ -14,7 +14,14 @@ Dynamic: license-file
14
14
  # Pystachy
15
15
 
16
16
  [![CI](https://github.com/den-run-ai/pystachy/actions/workflows/ci.yml/badge.svg?branch=main&event=push)](https://github.com/den-run-ai/pystachy/actions/workflows/ci.yml?query=branch%3Amain+event%3Apush)
17
+ [![Installation](https://github.com/den-run-ai/pystachy/actions/workflows/install.yml/badge.svg?branch=main&event=push)](https://github.com/den-run-ai/pystachy/actions/workflows/install.yml?query=branch%3Amain+event%3Apush)
18
+ [![Lint](https://github.com/den-run-ai/pystachy/actions/workflows/lint.yml/badge.svg?branch=main&event=push)](https://github.com/den-run-ai/pystachy/actions/workflows/lint.yml?query=branch%3Amain+event%3Apush)
19
+ [![Release](https://img.shields.io/github/v/release/den-run-ai/pystachy)](https://github.com/den-run-ai/pystachy/releases/latest)
20
+ [![PyPI](https://img.shields.io/pypi/v/pystachy?logo=pypi&logoColor=white)](https://pypi.org/project/pystachy/)
21
+ [![Docker](https://img.shields.io/docker/v/dta67/pystachy?sort=semver&logo=docker&logoColor=white&label=Docker)](https://hub.docker.com/r/dta67/pystachy)
17
22
  [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
23
+ [![Hosted compiler coverage](https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2Fden-run-ai%2Fpystachy%2Fbadges%2Fcoverage.json)](docs/testing.md#compiler-coverage)
24
+ [![Native runtime coverage](https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2Fden-run-ai%2Fpystachy%2Fbadges%2Fruntime-coverage.json)](docs/testing.md#native-runtime-coverage)
18
25
 
19
26
  Pystachy compiles a typed subset of Python to native code through LLVM. Use it
20
27
  for CPU-bound work such as text processing, data repair, and simulation while
@@ -23,7 +30,18 @@ modes share the same [typed intermediate representation](docs/typed-ir.md).
23
30
 
24
31
  ## Quick start
25
32
 
26
- Follow the [installation guide](docs/install.md), then save this as `demo.py`:
33
+ Install the [PyPI package](https://pypi.org/project/pystachy/) in a Python 3.11+
34
+ virtual environment:
35
+
36
+ ```sh
37
+ pip install pystachy
38
+ ```
39
+
40
+ The [installation guide](docs/install.md) covers LLVM requirements and automatic
41
+ toolchain setup. [Native archives](https://github.com/den-run-ai/pystachy/releases/latest) and
42
+ [Docker images](https://hub.docker.com/r/dta67/pystachy) are also available.
43
+
44
+ Then save this as `demo.py`:
27
45
 
28
46
  ```python
29
47
  from fnmatch import fnmatchcase
@@ -55,12 +73,15 @@ and shows how to measure compilation and execution separately.
55
73
  |---|---|
56
74
  | [Event router](examples/route/README.md) | Route logs and traces using pattern matching and memoization. |
57
75
  | [JSON repair](examples/json_repair/README.md) | Repair malformed JSON through a native CLI or a CPython extension. |
76
+ | [Byte BPE](examples/byte_bpe/README.md) | Train a byte tokenizer and encode/decode Unicode text natively. |
58
77
  | [Coding agent](examples/agent/README.md) | Run a typed tool loop and edit files from a native executable. |
59
78
  | [nanoGPT](examples/nanogpt/README.md) | Run inference and training with native arrays and optional BLAS. |
60
79
 
80
+ Browse [all examples](examples/README.md) for their purposes, checks and requirements.
61
81
  See the [performance guide](docs/performance.md) for measured workloads, startup
62
- and memory costs, and reproduction commands. `run` compiles the program on every
63
- invocation. `build` lets you reuse the executable.
82
+ and memory costs, and reproduction commands. On supported Linux native installs,
83
+ `run` automatically [reuses unchanged programs](docs/program-cache.md).
84
+ `PYSTACHY_PROGRAM_CACHE=0` forces compilation; `build` produces a standalone executable.
64
85
 
65
86
  ## Compatibility
66
87
 
@@ -68,12 +89,14 @@ Pystachy is experimental. It supports typed containers, classes, generators and
68
89
  other common Python constructs. General multiple inheritance, `async` and
69
90
  `match` are outside the supported subset. Integers are checked 64-bit values by
70
91
  default. [Promoting integers](docs/python-int.md) and [dynamic `Any`](docs/dynamic-any.md)
71
- are opt-in.
92
+ are opt-in. Dynamic `Any` includes a bounded prototype for
93
+ [class values, type-keyed registries, generic calls and annotated factories](docs/dynamic-any.md#class-values-and-type-keyed-registries).
72
94
 
73
95
  Check the [language guide](docs/language.md#support-at-a-glance) and
74
96
  [library support table](docs/stdlib.md#library-support-at-a-glance) for the
75
- features and APIs your code uses. The library includes bounded `argparse` and
76
- `enum` support. Some packages compile from installed sources, and others need
97
+ features and APIs your code uses. The library includes bounded `argparse`, `enum`
98
+ and experimental [static ctypes declarations](docs/ffi.md#static-ctypes-declarations).
99
+ Some packages compile from installed sources, and others need
77
100
  adaptations like the [maintained ports](ports/README.md). The optional
78
101
  [CPython bridge](docs/ffi.md#calling-cpython) lets native code call
79
102
  packages that need CPython at runtime.
@@ -1,7 +1,14 @@
1
1
  # Pystachy
2
2
 
3
3
  [![CI](https://github.com/den-run-ai/pystachy/actions/workflows/ci.yml/badge.svg?branch=main&event=push)](https://github.com/den-run-ai/pystachy/actions/workflows/ci.yml?query=branch%3Amain+event%3Apush)
4
+ [![Installation](https://github.com/den-run-ai/pystachy/actions/workflows/install.yml/badge.svg?branch=main&event=push)](https://github.com/den-run-ai/pystachy/actions/workflows/install.yml?query=branch%3Amain+event%3Apush)
5
+ [![Lint](https://github.com/den-run-ai/pystachy/actions/workflows/lint.yml/badge.svg?branch=main&event=push)](https://github.com/den-run-ai/pystachy/actions/workflows/lint.yml?query=branch%3Amain+event%3Apush)
6
+ [![Release](https://img.shields.io/github/v/release/den-run-ai/pystachy)](https://github.com/den-run-ai/pystachy/releases/latest)
7
+ [![PyPI](https://img.shields.io/pypi/v/pystachy?logo=pypi&logoColor=white)](https://pypi.org/project/pystachy/)
8
+ [![Docker](https://img.shields.io/docker/v/dta67/pystachy?sort=semver&logo=docker&logoColor=white&label=Docker)](https://hub.docker.com/r/dta67/pystachy)
4
9
  [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
10
+ [![Hosted compiler coverage](https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2Fden-run-ai%2Fpystachy%2Fbadges%2Fcoverage.json)](docs/testing.md#compiler-coverage)
11
+ [![Native runtime coverage](https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2Fden-run-ai%2Fpystachy%2Fbadges%2Fruntime-coverage.json)](docs/testing.md#native-runtime-coverage)
5
12
 
6
13
  Pystachy compiles a typed subset of Python to native code through LLVM. Use it
7
14
  for CPU-bound work such as text processing, data repair, and simulation while
@@ -10,7 +17,18 @@ modes share the same [typed intermediate representation](docs/typed-ir.md).
10
17
 
11
18
  ## Quick start
12
19
 
13
- Follow the [installation guide](docs/install.md), then save this as `demo.py`:
20
+ Install the [PyPI package](https://pypi.org/project/pystachy/) in a Python 3.11+
21
+ virtual environment:
22
+
23
+ ```sh
24
+ pip install pystachy
25
+ ```
26
+
27
+ The [installation guide](docs/install.md) covers LLVM requirements and automatic
28
+ toolchain setup. [Native archives](https://github.com/den-run-ai/pystachy/releases/latest) and
29
+ [Docker images](https://hub.docker.com/r/dta67/pystachy) are also available.
30
+
31
+ Then save this as `demo.py`:
14
32
 
15
33
  ```python
16
34
  from fnmatch import fnmatchcase
@@ -42,12 +60,15 @@ and shows how to measure compilation and execution separately.
42
60
  |---|---|
43
61
  | [Event router](examples/route/README.md) | Route logs and traces using pattern matching and memoization. |
44
62
  | [JSON repair](examples/json_repair/README.md) | Repair malformed JSON through a native CLI or a CPython extension. |
63
+ | [Byte BPE](examples/byte_bpe/README.md) | Train a byte tokenizer and encode/decode Unicode text natively. |
45
64
  | [Coding agent](examples/agent/README.md) | Run a typed tool loop and edit files from a native executable. |
46
65
  | [nanoGPT](examples/nanogpt/README.md) | Run inference and training with native arrays and optional BLAS. |
47
66
 
67
+ Browse [all examples](examples/README.md) for their purposes, checks and requirements.
48
68
  See the [performance guide](docs/performance.md) for measured workloads, startup
49
- and memory costs, and reproduction commands. `run` compiles the program on every
50
- invocation. `build` lets you reuse the executable.
69
+ and memory costs, and reproduction commands. On supported Linux native installs,
70
+ `run` automatically [reuses unchanged programs](docs/program-cache.md).
71
+ `PYSTACHY_PROGRAM_CACHE=0` forces compilation; `build` produces a standalone executable.
51
72
 
52
73
  ## Compatibility
53
74
 
@@ -55,12 +76,14 @@ Pystachy is experimental. It supports typed containers, classes, generators and
55
76
  other common Python constructs. General multiple inheritance, `async` and
56
77
  `match` are outside the supported subset. Integers are checked 64-bit values by
57
78
  default. [Promoting integers](docs/python-int.md) and [dynamic `Any`](docs/dynamic-any.md)
58
- are opt-in.
79
+ are opt-in. Dynamic `Any` includes a bounded prototype for
80
+ [class values, type-keyed registries, generic calls and annotated factories](docs/dynamic-any.md#class-values-and-type-keyed-registries).
59
81
 
60
82
  Check the [language guide](docs/language.md#support-at-a-glance) and
61
83
  [library support table](docs/stdlib.md#library-support-at-a-glance) for the
62
- features and APIs your code uses. The library includes bounded `argparse` and
63
- `enum` support. Some packages compile from installed sources, and others need
84
+ features and APIs your code uses. The library includes bounded `argparse`, `enum`
85
+ and experimental [static ctypes declarations](docs/ffi.md#static-ctypes-declarations).
86
+ Some packages compile from installed sources, and others need
64
87
  adaptations like the [maintained ports](ports/README.md). The optional
65
88
  [CPython bridge](docs/ffi.md#calling-cpython) lets native code call
66
89
  packages that need CPython at runtime.
@@ -86,6 +86,16 @@ adapt selected cases of that commit's Lib/test/test_contextlib.py and
86
86
  Lib/test/test_generators.py. They preserve the upstream assertions for the supported
87
87
  cases and disclose adaptations and exclusions; the same PSF license applies.
88
88
 
89
+ CPython's selected copyreg registration functions
90
+ ------------------------------------------------
91
+
92
+ tests/registrymods/copyreg_slice.py extracts pickle() and constructor() from
93
+ CPython 3.13.16's Lib/copyreg.py. Their bodies are unchanged. The marked
94
+ adaptations add the dynamic-Any opt-in and a type annotation for dispatch_table.
95
+ The fixture exercises registration and reducer dispatch, not the complete
96
+ copyreg module or pickle protocols. It uses the Python Software Foundation
97
+ License Version 2, retained in tests/upstream/CPYTHON-LICENSE.txt.
98
+
89
99
  CPython's dynamic core regression cases
90
100
  --------------------------------------
91
101
 
@@ -218,6 +228,12 @@ generated by tools/re_tables.py from CPython's Unicode functions and holds the t
218
228
  Lib/re/_casefix.py. They are derived from Python and are used under the same license and
219
229
  copyright notice.
220
230
 
231
+ runtime.c's unicode_classification table is generated by
232
+ tools/unicode_classification_tables.py from CPython 3.13.16's Unicode character
233
+ predicates (Unicode 15.1.0), encoded as property-flag transitions. It is derived
234
+ from Python and is used under the same license and copyright notice. The
235
+ underlying Unicode data is covered by "Unicode Character Database" below.
236
+
221
237
  lib/fnmatch.py is CPython 3.13.16's Lib/fnmatch.py with the edits lib/README.md lists, each
222
238
  marked in the source; it is derived from Python and is used under the same license and
223
239
  copyright notice.
@@ -334,14 +350,18 @@ documentation reproduces it from the original code:
334
350
  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
335
351
  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
336
352
 
337
- Unicode Character Database (lib/_pystachy_unicodedata_db.py, lib/_pystachy_unicodedata_names.py)
338
- --------------------------------------------------------------------------------------------------
353
+ Unicode Character Database (generated tables)
354
+ ---------------------------------------------
339
355
 
340
356
  The tables of lib/_pystachy_unicodedata_db.py and lib/_pystachy_unicodedata_names.py hold data of
341
357
  the Unicode Character Database 15.1.0 (https://www.unicode.org/ucd/), which
342
358
  tools/unicodedata_tables.py takes from CPython's unicodedata module and from the database's
343
- NameAliases.txt, NamedSequences.txt and NormalizationCorrections.txt. The data is used under the
344
- Unicode License V3:
359
+ NameAliases.txt, NamedSequences.txt and NormalizationCorrections.txt.
360
+ runtime.c's unicode_classification table also holds Unicode Character Database
361
+ 15.1.0 properties, generated by tools/unicode_classification_tables.py from
362
+ CPython 3.13.16's Unicode character predicates.
363
+
364
+ The data is used under the Unicode License V3:
345
365
 
346
366
  UNICODE LICENSE V3
347
367
 
@@ -520,7 +540,7 @@ Kuhn's code that wcwidth derives from.
520
540
  pyperformance (bench/pyperformance/)
521
541
  ------------------------------------
522
542
 
523
- The Python files in bench/pyperformance/ are the run_benchmark.py files of 24 benchmarks from
543
+ The Python files in bench/pyperformance/ are the run_benchmark.py files of 25 benchmarks from
524
544
  pyperformance 1.14.0 (https://github.com/python/pyperformance), edited where
525
545
  bench/pyperformance/README.md lists (each edit is marked "Pystachy port:"); that README records
526
546
  the sdist's and each file's SHA-256. pyperformance is used under the MIT License, whose text is in
@@ -536,6 +556,43 @@ richards_super.py credit a Java version "Copyright (C) 1995 Sun Microsystems, In
536
556
  MIT License; their origins are listed here so that a license review can confirm that this
537
557
  suffices.
538
558
 
559
+ Byte BPE (bench/pyperformance/bpe_tokeniser.py and examples/byte_bpe/upstream/bpe_tokeniser.py)
560
+ -------------------------------------------------------------------------------------------
561
+
562
+ The pyperformance byte-BPE benchmark credits its author Shantanu Jain and says it is based
563
+ on tiktoken (https://github.com/openai/tiktoken). The pristine benchmark and its unmodified
564
+ Mary Shelley Frankenstein excerpt, bench/pyperformance/data/frankenstein_intro.txt, come from
565
+ pyperformance 1.14.0 at commit 2ab96f98f98274d07ebfdfd66e4f021723179706; source paths and SHA-256
566
+ hashes are recorded in examples/byte_bpe/upstream/provenance.json. The excerpt is the fixture
567
+ bundled by pyperformance; it has no separate license header. The pyperformance MIT license
568
+ and author list are retained in bench/pyperformance/LICENSE and AUTHORS.
569
+
570
+ The benchmark does not identify its original tiktoken revision. The tiktoken MIT notice below
571
+ is reproduced from LICENSE at commit 4e71bbe0c078468e00fefbf94b39849389f346e5
572
+ (https://github.com/openai/tiktoken/blob/4e71bbe0c078468e00fefbf94b39849389f346e5/LICENSE):
573
+
574
+ MIT License
575
+
576
+ Copyright (c) 2022 OpenAI, Shantanu Jain
577
+
578
+ Permission is hereby granted, free of charge, to any person obtaining a copy
579
+ of this software and associated documentation files (the "Software"), to deal
580
+ in the Software without restriction, including without limitation the rights
581
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
582
+ copies of the Software, and to permit persons to whom the Software is
583
+ furnished to do so, subject to the following conditions:
584
+
585
+ The above copyright notice and this permission notice shall be included in all
586
+ copies or substantial portions of the Software.
587
+
588
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
589
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
590
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
591
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
592
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
593
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
594
+ SOFTWARE.
595
+
539
596
  Ryu (ryu/)
540
597
  ----------
541
598
 
@@ -569,14 +626,15 @@ CPython makes them; key= and the type-specialized compare functions are left out
569
626
  floats are merged with branch-free selects; and the merge buffer is memory that Pystachy's
570
627
  garbage collector scans.
571
628
 
572
- CPython's gamma functions and isclose() (runtime.c)
573
- ---------------------------------------------------
629
+ CPython's gamma functions and isclose() (runtime.c, runtime.py)
630
+ ------------------------------------------------------------
574
631
 
575
632
  math.gamma() and math.lgamma() in runtime.c (the section that starts with "math.gamma and
576
633
  math.lgamma are CPython 3.13.16's m_tgamma and m_lgamma") are CPython 3.13.16's m_sinpi,
577
634
  lanczos_sum, m_tgamma and m_lgamma from Modules/mathmodule.c (SHA-256
578
635
  e9370d6380c154d620ab7d5b54727aedb6c19e786156974445b965d1dd9a233a), with their constants and
579
- comments; pys_m_isclose, just before them, is that file's math_isclose_impl.
636
+ comments; pys_m_isclose in runtime.py is that file's math_isclose_impl, translated
637
+ to typed Python with the same comparisons and arithmetic order.
580
638
  They are a derivative work of Python and are used under the Python Software Foundation License
581
639
  Version 2, reproduced below. The changes: Python's Py_IS_FINITE, Py_IS_NAN, Py_IS_INFINITY,
582
640
  Py_NAN, Py_HUGE_VAL and Py_INFINITY are C99's, the asserts are dropped, Py_UNREACHABLE() is
pystachy-0.3.0/VERSION ADDED
@@ -0,0 +1 @@
1
+ v0.3.0
@@ -0,0 +1,20 @@
1
+ """Private native-program cache operations for the CLI compiler.
2
+
3
+ The native lock is nonblocking and stays on descriptor 9 until process exit or
4
+ exec. The compiler supplies the bounded wait and its CPython-hosted fallback.
5
+ Programs do not call the private runtime primitive directly.
6
+ """
7
+ import sys
8
+
9
+ __all__ = ["NATIVE", "try_lock", "file_hash"]
10
+ NATIVE: bool = sys.implementation.name == "pystachy"
11
+
12
+
13
+ def try_lock(path: str) -> int:
14
+ """Return 1 for an acquired lock, 0 for busy, and -1 for an unusable path."""
15
+ return __pys_cache_lock(path)
16
+
17
+
18
+ def file_hash(path: str, limit: int) -> str:
19
+ """Hash raw bytes with the cache's FNV digest, or return empty on failure."""
20
+ return __pys_cache_file_hash(path, limit)
@@ -0,0 +1,8 @@
1
+ """Native copying helper for ctypes' ordinary Python support classes."""
2
+ import ffi
3
+
4
+ __all__ = ["bytes_at"]
5
+
6
+
7
+ def bytes_at(address: int, size: int) -> bytes:
8
+ return ffi.bytes_at(address, size)
@@ -0,0 +1,89 @@
1
+ """Experimental static ctypes declarations; see docs/ffi.md.
2
+
3
+ The loader lowers literal CDLL/argtypes/restype blocks to ffi.extern. This
4
+ module supplies only the actual pointer cells and helpers used by those calls.
5
+ """
6
+ from _pystachy_ctypes import bytes_at as _bytes_at
7
+ from typing import Any
8
+
9
+ _Int = int
10
+ _Float = float
11
+ _Bytes = bytes | None
12
+ _Address = int | bool | None
13
+
14
+
15
+ class c_void_p:
16
+ """A pointer-sized output cell with an explicit lifetime."""
17
+
18
+ def __init__(self, value: _Address = None):
19
+ self._storage: list[int] = [_address(value)]
20
+
21
+ def __bool__(self) -> bool:
22
+ return self.value is not None
23
+
24
+ @property
25
+ def value(self) -> int | None:
26
+ return _pointer_value(self._storage[0])
27
+
28
+ @value.setter
29
+ def value(self, value: _Address) -> None:
30
+ self._storage[0] = _address(value)
31
+
32
+
33
+ class _Pointer:
34
+ def __init__(self, cell: c_void_p):
35
+ self._cell = cell
36
+
37
+
38
+ def byref(value: c_void_p) -> _Pointer:
39
+ """Borrow a c_void_p cell during a POINTER(c_void_p) call."""
40
+ return _Pointer(value)
41
+
42
+
43
+ def _byref_cell(value: c_void_p) -> c_void_p:
44
+ # The declaration lowerer uses this only for an immediately consumed byref.
45
+ # Keep its parameter check and evaluation point without allocating a wrapper.
46
+ return value
47
+
48
+
49
+ def string_at(address: Any, size: int = -1) -> bytes:
50
+ """Copy native bytes; -1 reads through the first NUL."""
51
+ return _bytes_at(_address(address), size)
52
+
53
+
54
+ def _address(value: Any) -> int:
55
+ checked = __pys_ctypes_value(value, "address")
56
+ if checked is None:
57
+ return 0
58
+ if checked < 0:
59
+ raise OverflowError("ctypes pointers require an address below 2**63")
60
+ return int(checked)
61
+
62
+
63
+ def _pointer_value(value: int) -> int | None:
64
+ value = _address(value)
65
+ return None if value == 0 else value
66
+
67
+
68
+ def _borrow(value: Any) -> list[int]:
69
+ cell = __pys_ctypes_value(value, "cell")
70
+ if len(cell._storage) != 1:
71
+ raise ValueError("ctypes pointer cells require exactly one storage slot")
72
+ return cell._storage
73
+
74
+
75
+ def _signed32(value: Any) -> int:
76
+ narrowed = int(__pys_ctypes_value(value, "integer")) & 4294967295
77
+ return narrowed - 4294967296 if narrowed >= 2147483648 else narrowed
78
+
79
+
80
+ def _unsigned32(value: Any) -> int:
81
+ return int(__pys_ctypes_value(value, "integer")) & 4294967295
82
+
83
+
84
+ def _integer(value: Any) -> int:
85
+ return int(__pys_ctypes_value(value, "integer"))
86
+
87
+
88
+ def _floating(value: Any) -> float:
89
+ return float(__pys_ctypes_value(value, "number"))
@@ -1,8 +1,8 @@
1
1
  """Explicit immutable arbitrary-precision integers, backed by the native runtime.
2
2
 
3
- Ordinary Pystachy int remains checked signed 64-bit. Construct mpz from an int
4
- or a string, and keep calculations in mpz to grow beyond that range. The
5
- CPython reference module in tools/rt_cpython delegates arithmetic to int.
3
+ Ordinary int is checked signed 64-bit by default; python-int is a separate
4
+ opt-in. Construct mpz from a signed 64-bit int or a string to select this class.
5
+ tools/rt_cpython/mpz_oracle.py provides an independent CPython-int oracle.
6
6
  """
7
7
 
8
8
  __all__ = ["mpz"]
@@ -13,7 +13,7 @@ import os
13
13
  import sys
14
14
  from ffi import extern, c_int, c_int64, c_ssize_t, c_void_p, c_buf, string_at, track, untrack, collected
15
15
 
16
- __all__ = ["Object", "import_module", "of_int", "of_float", "of_str", "of_list"]
16
+ __all__ = ["Object", "Buffer", "import_module", "of_int", "of_float", "of_str", "of_list"]
17
17
 
18
18
 
19
19
  @extern("python")
@@ -97,6 +97,20 @@ def pye_flush() -> None: ...
97
97
  @extern("")
98
98
  def pye_exit(e: c_void_p) -> None: ...
99
99
 
100
+ # pyembed.c: retained CPU-buffer ownership and the first bulk numerical consumer.
101
+ @extern("")
102
+ def pye_buffer_open(o: c_void_p, writable: c_int) -> c_void_p: ...
103
+ @extern("")
104
+ def pye_buffer_info(o: c_void_p, field: c_int) -> c_int64: ...
105
+ @extern("")
106
+ def pye_buffer_view(o: c_void_p, start: c_int64, count: c_int64, step: c_int64) -> c_void_p: ...
107
+ @extern("")
108
+ def pye_buffer_get(o: c_void_p, index: c_int64) -> float: ...
109
+ @extern("")
110
+ def pye_buffer_set(o: c_void_p, index: c_int64, value: float) -> c_int: ...
111
+ @extern("")
112
+ def pye_buffer_dot(left: c_void_p, right: c_void_p) -> float: ...
113
+
100
114
 
101
115
  _BUILTIN = ["KeyError", "IndexError", "ZeroDivisionError", "OverflowError", "ValueError", "TypeError",
102
116
  "AttributeError", "ModuleNotFoundError", "ImportError", "NotImplementedError", "RecursionError",
@@ -253,6 +267,16 @@ class Object:
253
267
  finally:
254
268
  _leave(g)
255
269
 
270
+ def buffer_f64(self, writable: bool = False) -> "Buffer":
271
+ g = _enter()
272
+ p = 0
273
+ try:
274
+ p = _own(self._p)
275
+ return _buffer(pye_buffer_open(p, 1 if writable else 0))
276
+ finally:
277
+ Py_DecRef(p)
278
+ _leave(g)
279
+
256
280
  def attr(self, name: str) -> "Object":
257
281
  g = _enter()
258
282
  p = 0
@@ -373,6 +397,111 @@ class Object:
373
397
  _leave(g)
374
398
 
375
399
 
400
+ def _buffer_info(owner: Object, field: int) -> int:
401
+ g = _enter()
402
+ p = 0
403
+ try:
404
+ p = _own(owner._p)
405
+ v = pye_buffer_info(p, field)
406
+ if PyErr_Occurred() != 0:
407
+ _raise()
408
+ return v
409
+ finally:
410
+ Py_DecRef(p)
411
+ _leave(g)
412
+
413
+
414
+ class Buffer:
415
+ # Private construction: each capsule owns an export or retains its root capsule.
416
+ # A view has an independent Object, so closing its parent cannot invalidate it.
417
+ def __init__(self, owner: Object) -> None:
418
+ self._owner = owner
419
+
420
+ def close(self) -> None:
421
+ self._owner.close()
422
+
423
+ def __len__(self) -> int:
424
+ return _buffer_info(self._owner, 0)
425
+
426
+ def dtype(self) -> str:
427
+ _buffer_info(self._owner, 0)
428
+ return "float64"
429
+
430
+ def shape(self) -> list[int]:
431
+ return [_buffer_info(self._owner, 0)]
432
+
433
+ def strides(self) -> list[int]:
434
+ return [_buffer_info(self._owner, 3)]
435
+
436
+ def offset(self) -> int:
437
+ return _buffer_info(self._owner, 2)
438
+
439
+ def nbytes(self) -> int:
440
+ return 8 * _buffer_info(self._owner, 0)
441
+
442
+ def storage_nbytes(self) -> int:
443
+ return _buffer_info(self._owner, 1)
444
+
445
+ def readonly(self) -> bool:
446
+ return _buffer_info(self._owner, 4) != 0
447
+
448
+ def view(self, start: int, count: int, step: int = 1) -> "Buffer":
449
+ g = _enter()
450
+ p = 0
451
+ try:
452
+ p = _own(self._owner._p)
453
+ return _buffer(pye_buffer_view(p, start, count, step))
454
+ finally:
455
+ Py_DecRef(p)
456
+ _leave(g)
457
+
458
+ def get(self, index: int) -> float:
459
+ g = _enter()
460
+ p = 0
461
+ try:
462
+ p = _own(self._owner._p)
463
+ v = pye_buffer_get(p, index)
464
+ if PyErr_Occurred() != 0:
465
+ _raise()
466
+ return v
467
+ finally:
468
+ Py_DecRef(p)
469
+ _leave(g)
470
+
471
+ def set(self, index: int, value: float) -> None:
472
+ g = _enter()
473
+ p = 0
474
+ try:
475
+ p = _own(self._owner._p)
476
+ if pye_buffer_set(p, index, value) < 0:
477
+ _raise()
478
+ finally:
479
+ Py_DecRef(p)
480
+ _leave(g)
481
+
482
+ def dot(self, other: "Buffer") -> float:
483
+ g = _enter()
484
+ p = 0
485
+ q = 0
486
+ try:
487
+ p = _own(self._owner._p)
488
+ q = _own(other._owner._p)
489
+ v = pye_buffer_dot(p, q)
490
+ if PyErr_Occurred() != 0:
491
+ _raise()
492
+ return v
493
+ finally:
494
+ Py_DecRef(q)
495
+ Py_DecRef(p)
496
+ _leave(g)
497
+
498
+
499
+ def _buffer(p: int) -> Buffer:
500
+ if p == 0:
501
+ _raise()
502
+ return Buffer(_ref(p, pye_buffer_info(p, 5)))
503
+
504
+
376
505
  def import_module(name: str) -> Object:
377
506
  g = _enter()
378
507
  try: