copium 0.1.0a1.dev122__cp310-cp310-macosx_11_0_arm64.whl

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.
_copium.pth ADDED
@@ -0,0 +1 @@
1
+ import os, sys; os.environ.get('COPIUM_PATCH_DEEPCOPY') == '1' and __import__('copium.patch').patch.enable()
copium/__about__.pyi ADDED
@@ -0,0 +1,25 @@
1
+ """Version information."""
2
+
3
+ from typing import Literal, NamedTuple, TypeVar, Final, Generic
4
+
5
+ NameT = TypeVar("NameT")
6
+ EmailT = TypeVar("EmailT")
7
+
8
+ class Author(NamedTuple, Generic[NameT, EmailT]):
9
+ name: NameT
10
+ email: EmailT
11
+
12
+ class VersionInfo(NamedTuple):
13
+ major: int
14
+ minor: int
15
+ patch: int
16
+ pre: str | None # 'a1,b2,rc3'
17
+ dev: int | None # number of commits since last tagged release
18
+ local: str # build hash, omitted from PyPI releases
19
+
20
+ __version__: str
21
+ __version_tuple__: VersionInfo
22
+ __commit_id__: str | None
23
+ __build_hash__: str
24
+
25
+ __authors__: Final[tuple[Author[Literal["Arseny Boykov (Bobronium)"], Literal["hi@bobronium.me"]]]]
copium/__init__.pyi ADDED
@@ -0,0 +1,31 @@
1
+ import sys
2
+ from copy import Error
3
+ from typing import Any, TypeVar
4
+
5
+ __all__ = ["copy", "deepcopy", "Error"]
6
+
7
+ T = TypeVar("T")
8
+
9
+ def copy(x: T) -> T:
10
+ """
11
+ Natively compiled copy.
12
+
13
+ :param x: object to copy.
14
+ :return: shallow copy of the `x`.
15
+ """
16
+
17
+ def deepcopy(x: T, memo: dict[int, Any] | None = None) -> T:
18
+ """
19
+ Natively compiled deepcopy.
20
+
21
+ :param x: object to deepcopy
22
+ :param memo: treat as opaque.
23
+ :return: deep copy of the `x`.
24
+ """
25
+
26
+ if sys.version_info >= (3, 13):
27
+ def replace(obj: T, /, **changes: Any) -> T:
28
+ """
29
+ Creates a new object of the same type as obj, replacing fields with values from changes.
30
+ """
31
+ __all__.append("replace")
copium/extra.pyi ADDED
@@ -0,0 +1,20 @@
1
+ from typing import Callable
2
+ from typing import TypeVar
3
+
4
+ __all__ = ["repeatcall", "replicate"]
5
+
6
+ T = TypeVar("T")
7
+
8
+ def repeatcall(function: Callable[[], T], size: int, /) -> list[T]:
9
+ """
10
+ Call function repeatedly size times and return the list of results.
11
+
12
+ Equivalent of [function() for _ in range(size)], but faster.
13
+ """
14
+
15
+ def replicate(obj: T, /, n: int) -> list[T]:
16
+ """
17
+ Returns n copies of the object in a list.
18
+
19
+ Equivalent of [deepcopy(obj) for _ in range(n)], but faster.
20
+ """
copium/patch.pyi ADDED
@@ -0,0 +1,20 @@
1
+ __all__ = ["enable", "disable", "enabled"]
2
+
3
+ def enable() -> bool:
4
+ """
5
+ Patch copy.deepcopy to use copium. Idempotent.
6
+
7
+ :return: True if state changed, False otherwise.
8
+ """
9
+
10
+ def disable() -> bool:
11
+ """
12
+ Restore original copy.deepcopy. Idempotent.
13
+
14
+ :return: True if state changed, False otherwise.
15
+ """
16
+
17
+ def enabled() -> bool:
18
+ """
19
+ :return: Whether copy.deepcopy is patched.
20
+ """
copium/py.typed ADDED
File without changes
@@ -0,0 +1,161 @@
1
+ Metadata-Version: 2.4
2
+ Name: copium
3
+ Version: 0.1.0a1.dev122
4
+ Summary: Fast drop-in replacement for copy.deepcopy()
5
+ Author-email: "Arseny Boykov (Bobronium)" <hi@bobronium.me>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/Bobronium/copium
8
+ Project-URL: Source, https://github.com/Bobronium/copium
9
+ Project-URL: Issues, https://github.com/Bobronium/copium/issues
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3 :: Only
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Programming Language :: Python :: 3.14
17
+ Classifier: Development Status :: 3 - Alpha
18
+ Classifier: Intended Audience :: Developers
19
+ Classifier: Topic :: Software Development :: Libraries
20
+ Requires-Python: >=3.10
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Provides-Extra: autopatch
24
+ Requires-Dist: copium-autopatch==0.1.0; extra == "autopatch"
25
+ Provides-Extra: dev
26
+ Requires-Dist: copium[lint]; extra == "dev"
27
+ Requires-Dist: copium[typecheck]; extra == "dev"
28
+ Requires-Dist: copium[test]; extra == "dev"
29
+ Requires-Dist: copium[docs]; extra == "dev"
30
+ Provides-Extra: lint
31
+ Requires-Dist: ruff>=0.5; extra == "lint"
32
+ Provides-Extra: typecheck
33
+ Requires-Dist: mypy>=1.10; extra == "typecheck"
34
+ Requires-Dist: pyright>=1.1.400; extra == "typecheck"
35
+ Requires-Dist: zuban>=0.2.0; extra == "typecheck"
36
+ Requires-Dist: pytest; extra == "typecheck"
37
+ Provides-Extra: test
38
+ Requires-Dist: pytest>=8; extra == "test"
39
+ Requires-Dist: pytest-assert-type>=0.1.5; extra == "test"
40
+ Requires-Dist: indifference>=0.1.0; extra == "test"
41
+ Requires-Dist: typing-extensions; python_version < "3.12" and extra == "test"
42
+ Requires-Dist: datamodelzoo; extra == "test"
43
+ Requires-Dist: pytest-codspeed>=4.2.0; extra == "test"
44
+ Requires-Dist: pytest-test-groups>=1.2.1; extra == "test"
45
+ Requires-Dist: psutil>=5.9.0; extra == "test"
46
+ Requires-Dist: pytest-random-order>=1.2.0; extra == "test"
47
+ Provides-Extra: docs
48
+ Requires-Dist: mkdocs-material; extra == "docs"
49
+ Requires-Dist: mkdocstrings[python]; extra == "docs"
50
+ Requires-Dist: mkdocs-autorefs; extra == "docs"
51
+ Requires-Dist: mkdocs-section-index; extra == "docs"
52
+ Provides-Extra: benchmark
53
+ Requires-Dist: tyro>=0.9.33; extra == "benchmark"
54
+ Requires-Dist: pyperf>=2.9.0; extra == "benchmark"
55
+ Requires-Dist: ipython>=8.37.0; extra == "benchmark"
56
+ Requires-Dist: datamodelzoo; extra == "benchmark"
57
+ Provides-Extra: build
58
+ Requires-Dist: build>=1.3.0; extra == "build"
59
+ Requires-Dist: cibuildwheel>=2.23.3; extra == "build"
60
+ Requires-Dist: pip>=25.3; extra == "build"
61
+ Requires-Dist: setuptools>=80.9.0; extra == "build"
62
+ Requires-Dist: setuptools-scm>=9.2.2; extra == "build"
63
+ Requires-Dist: wheel>=0.45.1; extra == "build"
64
+ Dynamic: license-file
65
+
66
+ <h1>
67
+ copium
68
+ <a href="https://pypi.python.org/pypi/copium">
69
+ <img src="https://img.shields.io/pypi/v/copium.svg" alt="PyPI Version Badge">
70
+ </a>
71
+ <a href="https://pypi.python.org/pypi/copium">
72
+ <img src="https://img.shields.io/pypi/l/copium.svg" alt="PyPI License Badge">
73
+ </a>
74
+ <a href="https://pypi.python.org/pypi/copium">
75
+ <img src="https://img.shields.io/pypi/pyversions/copium.svg" alt="PyPI Python Versions Badge">
76
+ </a>
77
+ <a href="https://github.com/Bobronium/copium/actions">
78
+ <img src="https://github.com/Bobronium/copium/actions/workflows/cd.yaml/badge.svg" alt="CD Status Badge">
79
+ </a>
80
+ <a href="https://codspeed.io/Bobronium/copium">
81
+ <img src="https://img.shields.io/badge/Codspeed-copium-8A2BE2?style=flat&logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA0MCA0MCIgcHJlc2VydmVBc3BlY3RSYXRpbz0ieE1pZFlNaWQgbWVldCI%2BCiAgICA8ZyB0cmFuc2Zvcm09InRyYW5zbGF0ZSgtMTAwLDEwKSB0cmFuc2xhdGUoMTIwLDEyKSBzY2FsZSgxLjMpIHRyYW5zbGF0ZSgtMTIwLC0xMikiPiI%2BCiAgICAgICAgPHBhdGggZmlsbD0iI0VENkUzRCIgZmlsbC1ydWxlPSJldmVub2RkIgogICAgICAgICAgICAgIGQ9Ik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zAgMS4wODMtMi4zMDguNDM0LTQuOTc2LjMxOGE5IDkgMCAwIDAtLjYxLS4wMDJjLTEuMDg5LS4wNTUtMS45ODUtLjM3NC0zLjE4Ni0uOTc0bC4wMjEtLjAwNHMtLjA5Mi0uMDM4LS4yMzgtLjEwNmMtLjM1Ni0uMTgyLS43NC0uMzg3LTEuMTYyLS42MTZoLS4wMDNjLS4zOTgtLjI0OC0uNzQ5LS41MjctLjgzOC0uNzc2LS4yMzMtLjY1MS0uMTE4LS42NTEuNzE1LTEuNjEzLTEuNDIyLjE3NS0xLjQ1Ny4yNzYtMy4wNzguMjc2cy00LjI5Mi0uMDgzLTQuMjkyLTEuNjdxMC0xLjU5IDIuMTYxLTEuMjM2LS41MjctMi44OSAxLjgwNy01LjJjNC4wNzYtNC4wMzUgOS41NzggMS41MjUgMTMuMzUgMS41MjUgMS43MTYgMC0zLjAyNS0yLjY5My00Ljk5NS0zLjQ1NnMxLjEzMS0zLjcyOSAzLjk3OC0xLjYyNG00Ljc0OCA1LjU1MmMtLjMxIDAtLjU2MS4yNy0uNTYxLjYwNXMuMjUxLjYwNC41NjEuNjA0LjU2MS0uMjcuNTYxLS42MDQtLjI1MS0uNjA1LS41NjEtLjYwNSIKICAgICAgICAgICAgICBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz4KICAgIDwvZz4KPC9zdmc%2B&logoSize=auto&labelColor=1B2330&color=ED6E3D&link=https%3A%2F%2Fcodspeed.io%2FBobronium%2Fcopium" alt="Codspeed Badge">
82
+ </a>
83
+ </h1>
84
+
85
+
86
+ Fast drop-in replacement for `copy.deepcopy()`.
87
+
88
+ <picture>
89
+ <source srcset="https://raw.githubusercontent.com/Bobronium/copium/4ca9135187020f75fa4b3373d2272f2efd060b2c/assets/copium_logo_512.png" media="(prefers-color-scheme: dark)">
90
+ <source srcset="https://raw.githubusercontent.com/Bobronium/copium/4ca9135187020f75fa4b3373d2272f2efd060b2c/assets/copium_logo_light_512.png" media="(prefers-color-scheme: light)">
91
+ <img src="https://raw.githubusercontent.com/Bobronium/copium/4ca9135187020f75fa4b3373d2272f2efd060b2c/assets/copium_logo_512.png" alt="Copium Logo" width="200" align="left">
92
+ </picture>
93
+
94
+ <div align="center">
95
+ <picture>
96
+ <source srcset="https://raw.githubusercontent.com/Bobronium/copium/f1fedb8319e513506d50317f9100b0ca171dc9a8/assets/chart_dark.svg" media="(prefers-color-scheme: dark)">
97
+ <source srcset="https://raw.githubusercontent.com/Bobronium/copium/f1fedb8319e513506d50317f9100b0ca171dc9a8/assets/chart_light.svg" media="(prefers-color-scheme: light)">
98
+ <img src="https://raw.githubusercontent.com/Bobronium/copium/f1fedb8319e513506d50317f9100b0ca171dc9a8/assets/chart_light.svg" alt="Benchmark results bar chart" width="600">
99
+ </picture>
100
+ </div>
101
+ <div align="center">
102
+ <i>Benchmarked on <a href="https://github.com/Bobronium/copium/actions/workflows/build.yaml">GitHub Actions</a> using <a href="https://github.com/Bobronium/copium/blob/b3d838c5474a4afa4f639c96b27ebdc12cc00cf4/tools/run_benchmark.py">tools/run_benchmark.py</a>, charted with <a href="https://github.com/Bobronium/copium/blob/b3d838c5474a4afa4f639c96b27ebdc12cc00cf4/tools/generate_chart.py">tools/generate_chart.py</a></i>
103
+ </div>
104
+
105
+ ## Highlights
106
+
107
+ - โšก 4-28x faster than `copy.deepcopy()` on builtin types
108
+ - ๐Ÿง  uses ~44% less memory than `copy.deepcopy()` on average
109
+ - ๐Ÿงช passes all tests in `CPython/Lib/test/test_copy.py`
110
+ - ๐ŸŽฏ behaves exactly the same as `copy.deepcopy()` for all [`datamodelzoo.CASES`](https://github.com/Bobronium/datamodelzoo/blob/00ec1632b4037670628c865a0db2c8bc259abb75/src/datamodelzoo/__init__.py#L18)
111
+ - ๐Ÿ›ก๏ธ tested for refcount, recursion, threading and memo edge cases
112
+ - ๐Ÿ pre-built wheels for Python 3.10-3.14 on Linux/macOS/Windows (x64/ARM64)
113
+ - ๐Ÿ”“ passes all tesee-frts on threaded Pyth buildons
114
+
115
+ ## Installation
116
+
117
+ > [!WARNING]
118
+ > This is an alpha version.
119
+
120
+ ```bash
121
+ pip install copium
122
+ ```
123
+
124
+
125
+ ## Usage
126
+
127
+ Simply export `COPIUM_PATCH_DEEPCOPY=1` before running your application. You
128
+ don't have to change a single line of code:
129
+
130
+ `cat example.py`
131
+
132
+ ```python
133
+ from copy import deepcopy
134
+
135
+ assert deepcopy(x := []) is not x
136
+ ```
137
+
138
+ `COPIUM_PATCH_DEEPCOPY=1 python example.py`
139
+
140
+ ### To enable the patch manually:
141
+
142
+ ```py
143
+ import copium.patch
144
+
145
+ copium.patch.enable()
146
+ ```
147
+
148
+ ### To use manually:
149
+
150
+ ```py
151
+ from copium import deepcopy
152
+
153
+ assert deepcopy(x := []) is not x
154
+ ```
155
+
156
+ The `copium` module includes all public declarations of stdlib `copy` module, so it's generally safe to:
157
+
158
+ ```diff
159
+ - from copy import copy, deepcopy, Error
160
+ + from copium import copy, deepcopy, Error
161
+ ```
@@ -0,0 +1,12 @@
1
+ _copium.pth,sha256=UcSx17eEUd8h7uYOesLl2XDMl1mR8YVEJUdkCZg-SHA,109
2
+ copium.cpython-310-darwin.so,sha256=qH0HHGfPzqauEpV9AjNgBDESlhbIMMrTpCaFqZb2svQ,254416
3
+ copium/patch.pyi,sha256=XCOyDf0VQiEjeKT86xtFyRLh-sBEAMwnlElF1bdBILg,416
4
+ copium/__init__.pyi,sha256=mZaGBbGEozD_sbTBpvFPvXGnC70mebTn2Rl2_zCRmVE,706
5
+ copium/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ copium/__about__.pyi,sha256=C1p_jYV7aXPcgAZbeEyDDehrCaOmItsobsDpnKulFtE,662
7
+ copium/extra.pyi,sha256=W8KY9J8DhEtNHSjRpt2SAlSrTkgKfb_Tnw226olbMBc,509
8
+ copium-0.1.0a1.dev122.dist-info/RECORD,,
9
+ copium-0.1.0a1.dev122.dist-info/WHEEL,sha256=Q6bc0ESWeYWqmaiEFX3NMAiRkqNPaD38f90ndCFiBs8,137
10
+ copium-0.1.0a1.dev122.dist-info/top_level.txt,sha256=GZDlOGAVPhG7xdRAtxyamzeXrv8DCjarx47lcsT-XFI,7
11
+ copium-0.1.0a1.dev122.dist-info/METADATA,sha256=5Su_mtzN9UiZhD3YcJ5LETBf4OGWgpKnEtDCxppi06w,8842
12
+ copium-0.1.0a1.dev122.dist-info/licenses/LICENSE,sha256=3Nm-Fdi9jP4UjMdVZWoM3atU0HLcXBaVr-navSWVWr4,1100
@@ -0,0 +1,6 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.10.1)
3
+ Root-Is-Purelib: false
4
+ Tag: cp310-cp310-macosx_11_0_arm64
5
+ Generator: delocate 0.13.0
6
+
@@ -0,0 +1,18 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Arseny Boykov (Bobronium) <hi@bobronium.me>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
6
+ associated documentation files (the "Software"), to deal in the Software without restriction, including
7
+ without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
9
+ following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all copies or substantial
12
+ portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
15
+ LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
16
+ EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
18
+ USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1 @@
1
+ copium
Binary file