collex 0.1.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 (38) hide show
  1. collex-0.1.0/LICENSE.cpython +277 -0
  2. collex-0.1.0/MANIFEST.in +5 -0
  3. collex-0.1.0/PKG-INFO +88 -0
  4. collex-0.1.0/README.md +78 -0
  5. collex-0.1.0/benchmarks/containers.py +363 -0
  6. collex-0.1.0/docs/api.md +29 -0
  7. collex-0.1.0/docs/benchmarks.md +373 -0
  8. collex-0.1.0/docs/native-safety.md +30 -0
  9. collex-0.1.0/pyproject.toml +42 -0
  10. collex-0.1.0/setup.cfg +4 -0
  11. collex-0.1.0/setup.py +36 -0
  12. collex-0.1.0/src/collex/__init__.py +14 -0
  13. collex-0.1.0/src/collex/_ordered.pyi +24 -0
  14. collex-0.1.0/src/collex/_proxy.pyi +30 -0
  15. collex-0.1.0/src/collex/casefold.py +685 -0
  16. collex-0.1.0/src/collex/identity/__init__.py +4 -0
  17. collex-0.1.0/src/collex/identity/__init__.pyi +99 -0
  18. collex-0.1.0/src/collex/identity/dict.c +1083 -0
  19. collex-0.1.0/src/collex/identity/dict.h +65 -0
  20. collex-0.1.0/src/collex/identity/set.c +1628 -0
  21. collex-0.1.0/src/collex/identity/set.h +18 -0
  22. collex-0.1.0/src/collex/identity/views.c +631 -0
  23. collex-0.1.0/src/collex/keyeddict.py +179 -0
  24. collex-0.1.0/src/collex/ordered.c +2006 -0
  25. collex-0.1.0/src/collex/proxy.c +356 -0
  26. collex-0.1.0/src/collex/proxy.py +12 -0
  27. collex-0.1.0/src/collex/py.typed +0 -0
  28. collex-0.1.0/src/collex.egg-info/PKG-INFO +88 -0
  29. collex-0.1.0/src/collex.egg-info/SOURCES.txt +36 -0
  30. collex-0.1.0/src/collex.egg-info/dependency_links.txt +1 -0
  31. collex-0.1.0/src/collex.egg-info/top_level.txt +1 -0
  32. collex-0.1.0/tests/test_containers.py +585 -0
  33. collex-0.1.0/tests/test_differential.py +73 -0
  34. collex-0.1.0/tests/test_identity_set.py +641 -0
  35. collex-0.1.0/tests/test_keyed_dict.py +315 -0
  36. collex-0.1.0/tests/test_native.py +1334 -0
  37. collex-0.1.0/tests/test_typing.py +80 -0
  38. collex-0.1.0/tools/check-native.sh +44 -0
@@ -0,0 +1,277 @@
1
+ A. HISTORY OF THE SOFTWARE
2
+ ==========================
3
+
4
+ Python was created in the early 1990s by Guido van Rossum at Stichting
5
+ Mathematisch Centrum (CWI, see https://www.cwi.nl) in the Netherlands
6
+ as a successor of a language called ABC. Guido remains Python's
7
+ principal author, although it includes many contributions from others.
8
+
9
+ In 1995, Guido continued his work on Python at the Corporation for
10
+ National Research Initiatives (CNRI, see https://www.cnri.reston.va.us)
11
+ in Reston, Virginia where he released several versions of the
12
+ software.
13
+
14
+ In May 2000, Guido and the Python core development team moved to
15
+ BeOpen.com to form the BeOpen PythonLabs team. In October of the same
16
+ year, the PythonLabs team moved to Digital Creations, which became
17
+ Zope Corporation. In 2001, the Python Software Foundation (PSF, see
18
+ https://www.python.org/psf/) was formed, a non-profit organization
19
+ created specifically to own Python-related Intellectual Property.
20
+ Zope Corporation was a sponsoring member of the PSF.
21
+
22
+ All Python releases are Open Source (see https://opensource.org for
23
+ the Open Source Definition). Historically, most, but not all, Python
24
+ releases have also been GPL-compatible; the table below summarizes
25
+ the various releases.
26
+
27
+ Release Derived Year Owner GPL-
28
+ from compatible? (1)
29
+
30
+ 0.9.0 thru 1.2 1991-1995 CWI yes
31
+ 1.3 thru 1.5.2 1.2 1995-1999 CNRI yes
32
+ 1.6 1.5.2 2000 CNRI no
33
+ 2.0 1.6 2000 BeOpen.com no
34
+ 1.6.1 1.6 2001 CNRI yes (2)
35
+ 2.1 2.0+1.6.1 2001 PSF no
36
+ 2.0.1 2.0+1.6.1 2001 PSF yes
37
+ 2.1.1 2.1+2.0.1 2001 PSF yes
38
+ 2.1.2 2.1.1 2002 PSF yes
39
+ 2.1.3 2.1.2 2002 PSF yes
40
+ 2.2 and above 2.1.1 2001-now PSF yes
41
+
42
+ Footnotes:
43
+
44
+ (1) GPL-compatible doesn't mean that we're distributing Python under
45
+ the GPL. All Python licenses, unlike the GPL, let you distribute
46
+ a modified version without making your changes open source. The
47
+ GPL-compatible licenses make it possible to combine Python with
48
+ other software that is released under the GPL; the others don't.
49
+
50
+ (2) According to Richard Stallman, 1.6.1 is not GPL-compatible,
51
+ because its license has a choice of law clause. According to
52
+ CNRI, however, Stallman's lawyer has told CNRI's lawyer that 1.6.1
53
+ is "not incompatible" with the GPL.
54
+
55
+ Thanks to the many outside volunteers who have worked under Guido's
56
+ direction to make these releases possible.
57
+
58
+
59
+ B. TERMS AND CONDITIONS FOR ACCESSING OR OTHERWISE USING PYTHON
60
+ ===============================================================
61
+
62
+ Python software and documentation are licensed under the
63
+ Python Software Foundation License Version 2.
64
+
65
+ Starting with Python 3.8.6, examples, recipes, and other code in
66
+ the documentation are dual licensed under the PSF License Version 2
67
+ and the Zero-Clause BSD license.
68
+
69
+ Some software incorporated into Python is under different licenses.
70
+ The licenses are listed with code falling under that license.
71
+
72
+
73
+ PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
74
+ --------------------------------------------
75
+
76
+ 1. This LICENSE AGREEMENT is between the Python Software Foundation
77
+ ("PSF"), and the Individual or Organization ("Licensee") accessing and
78
+ otherwise using this software ("Python") in source or binary form and
79
+ its associated documentation.
80
+
81
+ 2. Subject to the terms and conditions of this License Agreement, PSF hereby
82
+ grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce,
83
+ analyze, test, perform and/or display publicly, prepare derivative works,
84
+ distribute, and otherwise use Python alone or in any derivative version,
85
+ provided, however, that PSF's License Agreement and PSF's notice of copyright,
86
+ i.e., "Copyright (c) 2001 Python Software Foundation; All Rights Reserved"
87
+ are retained in Python alone or in any derivative version prepared by Licensee.
88
+
89
+ 3. In the event Licensee prepares a derivative work that is based on
90
+ or incorporates Python or any part thereof, and wants to make
91
+ the derivative work available to others as provided herein, then
92
+ Licensee hereby agrees to include in any such work a brief summary of
93
+ the changes made to Python.
94
+
95
+ 4. PSF is making Python available to Licensee on an "AS IS"
96
+ basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
97
+ IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND
98
+ DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
99
+ FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON WILL NOT
100
+ INFRINGE ANY THIRD PARTY RIGHTS.
101
+
102
+ 5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON
103
+ FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS
104
+ A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON,
105
+ OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
106
+
107
+ 6. This License Agreement will automatically terminate upon a material
108
+ breach of its terms and conditions.
109
+
110
+ 7. Nothing in this License Agreement shall be deemed to create any
111
+ relationship of agency, partnership, or joint venture between PSF and
112
+ Licensee. This License Agreement does not grant permission to use PSF
113
+ trademarks or trade name in a trademark sense to endorse or promote
114
+ products or services of Licensee, or any third party.
115
+
116
+ 8. By copying, installing or otherwise using Python, Licensee
117
+ agrees to be bound by the terms and conditions of this License
118
+ Agreement.
119
+
120
+
121
+ BEOPEN.COM LICENSE AGREEMENT FOR PYTHON 2.0
122
+ -------------------------------------------
123
+
124
+ BEOPEN PYTHON OPEN SOURCE LICENSE AGREEMENT VERSION 1
125
+
126
+ 1. This LICENSE AGREEMENT is between BeOpen.com ("BeOpen"), having an
127
+ office at 160 Saratoga Avenue, Santa Clara, CA 95051, and the
128
+ Individual or Organization ("Licensee") accessing and otherwise using
129
+ this software in source or binary form and its associated
130
+ documentation ("the Software").
131
+
132
+ 2. Subject to the terms and conditions of this BeOpen Python License
133
+ Agreement, BeOpen hereby grants Licensee a non-exclusive,
134
+ royalty-free, world-wide license to reproduce, analyze, test, perform
135
+ and/or display publicly, prepare derivative works, distribute, and
136
+ otherwise use the Software alone or in any derivative version,
137
+ provided, however, that the BeOpen Python License is retained in the
138
+ Software, alone or in any derivative version prepared by Licensee.
139
+
140
+ 3. BeOpen is making the Software available to Licensee on an "AS IS"
141
+ basis. BEOPEN MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
142
+ IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, BEOPEN MAKES NO AND
143
+ DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
144
+ FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE WILL NOT
145
+ INFRINGE ANY THIRD PARTY RIGHTS.
146
+
147
+ 4. BEOPEN SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF THE
148
+ SOFTWARE FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS
149
+ AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THE SOFTWARE, OR ANY
150
+ DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
151
+
152
+ 5. This License Agreement will automatically terminate upon a material
153
+ breach of its terms and conditions.
154
+
155
+ 6. This License Agreement shall be governed by and interpreted in all
156
+ respects by the law of the State of California, excluding conflict of
157
+ law provisions. Nothing in this License Agreement shall be deemed to
158
+ create any relationship of agency, partnership, or joint venture
159
+ between BeOpen and Licensee. This License Agreement does not grant
160
+ permission to use BeOpen trademarks or trade names in a trademark
161
+ sense to endorse or promote products or services of Licensee, or any
162
+ third party. As an exception, the "BeOpen Python" logos available at
163
+ http://www.pythonlabs.com/logos.html may be used according to the
164
+ permissions granted on that web page.
165
+
166
+ 7. By copying, installing or otherwise using the software, Licensee
167
+ agrees to be bound by the terms and conditions of this License
168
+ Agreement.
169
+
170
+
171
+ CNRI LICENSE AGREEMENT FOR PYTHON 1.6.1
172
+ ---------------------------------------
173
+
174
+ 1. This LICENSE AGREEMENT is between the Corporation for National
175
+ Research Initiatives, having an office at 1895 Preston White Drive,
176
+ Reston, VA 20191 ("CNRI"), and the Individual or Organization
177
+ ("Licensee") accessing and otherwise using Python 1.6.1 software in
178
+ source or binary form and its associated documentation.
179
+
180
+ 2. Subject to the terms and conditions of this License Agreement, CNRI
181
+ hereby grants Licensee a nonexclusive, royalty-free, world-wide
182
+ license to reproduce, analyze, test, perform and/or display publicly,
183
+ prepare derivative works, distribute, and otherwise use Python 1.6.1
184
+ alone or in any derivative version, provided, however, that CNRI's
185
+ License Agreement and CNRI's notice of copyright, i.e., "Copyright (c)
186
+ 1995-2001 Corporation for National Research Initiatives; All Rights
187
+ Reserved" are retained in Python 1.6.1 alone or in any derivative
188
+ version prepared by Licensee. Alternately, in lieu of CNRI's License
189
+ Agreement, Licensee may substitute the following text (omitting the
190
+ quotes): "Python 1.6.1 is made available subject to the terms and
191
+ conditions in CNRI's License Agreement. This Agreement together with
192
+ Python 1.6.1 may be located on the internet using the following
193
+ unique, persistent identifier (known as a handle): 1895.22/1013. This
194
+ Agreement may also be obtained from a proxy server on the internet
195
+ using the following URL: http://hdl.handle.net/1895.22/1013".
196
+
197
+ 3. In the event Licensee prepares a derivative work that is based on
198
+ or incorporates Python 1.6.1 or any part thereof, and wants to make
199
+ the derivative work available to others as provided herein, then
200
+ Licensee hereby agrees to include in any such work a brief summary of
201
+ the changes made to Python 1.6.1.
202
+
203
+ 4. CNRI is making Python 1.6.1 available to Licensee on an "AS IS"
204
+ basis. CNRI MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
205
+ IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, CNRI MAKES NO AND
206
+ DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
207
+ FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON 1.6.1 WILL NOT
208
+ INFRINGE ANY THIRD PARTY RIGHTS.
209
+
210
+ 5. CNRI SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON
211
+ 1.6.1 FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS
212
+ A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON 1.6.1,
213
+ OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
214
+
215
+ 6. This License Agreement will automatically terminate upon a material
216
+ breach of its terms and conditions.
217
+
218
+ 7. This License Agreement shall be governed by the federal
219
+ intellectual property law of the United States, including without
220
+ limitation the federal copyright law, and, to the extent such
221
+ U.S. federal law does not apply, by the law of the Commonwealth of
222
+ Virginia, excluding Virginia's conflict of law provisions.
223
+ Notwithstanding the foregoing, with regard to derivative works based
224
+ on Python 1.6.1 that incorporate non-separable material that was
225
+ previously distributed under the GNU General Public License (GPL), the
226
+ law of the Commonwealth of Virginia shall govern this License
227
+ Agreement only as to issues arising under or with respect to
228
+ Paragraphs 4, 5, and 7 of this License Agreement. Nothing in this
229
+ License Agreement shall be deemed to create any relationship of
230
+ agency, partnership, or joint venture between CNRI and Licensee. This
231
+ License Agreement does not grant permission to use CNRI trademarks or
232
+ trade name in a trademark sense to endorse or promote products or
233
+ services of Licensee, or any third party.
234
+
235
+ 8. By clicking on the "ACCEPT" button where indicated, or by copying,
236
+ installing or otherwise using Python 1.6.1, Licensee agrees to be
237
+ bound by the terms and conditions of this License Agreement.
238
+
239
+ ACCEPT
240
+
241
+
242
+ CWI LICENSE AGREEMENT FOR PYTHON 0.9.0 THROUGH 1.2
243
+ --------------------------------------------------
244
+
245
+ Copyright (c) 1991 - 1995, Stichting Mathematisch Centrum Amsterdam,
246
+ The Netherlands. All rights reserved.
247
+
248
+ Permission to use, copy, modify, and distribute this software and its
249
+ documentation for any purpose and without fee is hereby granted,
250
+ provided that the above copyright notice appear in all copies and that
251
+ both that copyright notice and this permission notice appear in
252
+ supporting documentation, and that the name of Stichting Mathematisch
253
+ Centrum or CWI not be used in advertising or publicity pertaining to
254
+ distribution of the software without specific, written prior
255
+ permission.
256
+
257
+ STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
258
+ THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
259
+ FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
260
+ FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
261
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
262
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
263
+ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
264
+
265
+ ZERO-CLAUSE BSD LICENSE FOR CODE IN THE PYTHON DOCUMENTATION
266
+ ----------------------------------------------------------------------
267
+
268
+ Permission to use, copy, modify, and/or distribute this software for any
269
+ purpose with or without fee is hereby granted.
270
+
271
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
272
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
273
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
274
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
275
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
276
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
277
+ PERFORMANCE OF THIS SOFTWARE.
@@ -0,0 +1,5 @@
1
+ include src/collex/identity/dict.h
2
+ include src/collex/identity/set.h
3
+ include benchmarks/containers.py
4
+ include docs/*.md
5
+ include tools/check-native.sh
collex-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,88 @@
1
+ Metadata-Version: 2.4
2
+ Name: collex
3
+ Version: 0.1.0
4
+ Summary: Ordered, identity-based and case-folded containers and read-only views
5
+ Classifier: Programming Language :: Python :: Implementation :: CPython
6
+ Requires-Python: <3.16,>=3.15
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE.cpython
9
+ Dynamic: license-file
10
+
11
+ # collex
12
+
13
+ Containers for CPython 3.15 with the GIL enabled. The development interpreter is
14
+ CPython 3.15.2. Free-threaded CPython and subinterpreters are unsupported.
15
+ The native extensions depend on CPython layouts and are built per minor version.
16
+
17
+ - `OrderedDict` supports inserting and moving entries relative to existing keys.
18
+ - `IdentityDict` and `IdentitySet` compare objects by identity and accept unhashable objects.
19
+ - `KeyedDict` and `KeyedOrderedDict` derive keys from values.
20
+ - `CaseFoldDict`, `FrozenCaseFoldDict`, `CaseFoldSet`, and `FrozenCaseFoldSet` support Unicode case-folded lookups.
21
+ - `SequenceProxy`, `SetProxy`, and `MappingProxy` provide live read-only views of their backing containers.
22
+
23
+ `IdentityDict` uses a compact insertion-ordered identity table. Probing
24
+ compares object pointers directly. The table owns references to both keys and
25
+ values, and its views iterate the entries in place.
26
+
27
+ `IdentitySet` stores one object pointer per table slot and derives the hash
28
+ from that pointer. Probing compares object pointers directly.
29
+ Iteration order is unspecified, and `pop()` removes an arbitrary member.
30
+ Set operators take identity sets, identity keys views, sets, and frozensets on
31
+ the right. The named set operations accept any iterable, with membership matched
32
+ by identity. Comparisons support identity sets and identity keys views. Intersection
33
+ and `isdisjoint()` between identity containers scan the cheaper table where
34
+ both operands expose identity membership.
35
+
36
+ A new `OrderedDict` entry normally goes at the end. Use
37
+ `insert_before(anchor, key, value)` or `insert_after(anchor, key, value)` to choose
38
+ its position. These methods require
39
+ an existing anchor and a new key. Use `move_before(key, anchor)`,
40
+ `move_after(key, anchor)`, or `move_to_end(key, last=False)` to reposition an
41
+ existing entry. The vendored implementation is based on CPython 3.15.2's
42
+ `Objects/odictobject.c`. It is a `dict` subtype and uses an independent hash
43
+ index to find linked-list nodes. Relative positioning takes expected constant
44
+ time, with amortized constant-time insertion.
45
+
46
+ `peek_before(anchor)` and `peek_after(anchor)` return the adjacent key. They
47
+ raise `KeyError` when the anchor or neighbor is missing. `swap(first, second)`
48
+ exchanges the positions of two existing keys. These operations take expected
49
+ constant time. Use `next(iter(mapping))` and `next(reversed(mapping))` for the
50
+ first and last keys.
51
+ Use the ordered mapping's methods to mutate it. Explicit calls such as
52
+ `dict.__setitem__(ordered, key, value)` bypass the linked-list index and are
53
+ unsupported.
54
+
55
+ With `KeyedOrderedDict`, pass only the value after the anchor when inserting.
56
+ The key comes from the configured projection.
57
+
58
+ Mapping views stay live, support reverse iteration, and expose a read-only
59
+ `.mapping` attribute. Keys and items support set comparisons and operations.
60
+ `IdentityDict.keys()` compares with other identity keys views and `IdentitySet`.
61
+ Its set operations match objects by identity and return `IdentitySet`, including
62
+ when keys are unhashable. `IdentityDict.items()` matches keys by identity and
63
+ values by equality. Its set operations return Python sets of hashable pairs.
64
+ Its comparisons support other identity items views.
65
+
66
+ The `.casefolded` property gives direct access to canonical keys or members
67
+ without folding lookups again. Mutable containers expose live read-only proxies.
68
+ Frozen containers expose their immutable `frozendict` or `frozenset` storage.
69
+
70
+ `SetProxy` delegates set operators and comparisons to its backing set.
71
+ Results have the type and semantics supplied by the operands. The proxies
72
+ retain their backing containers and reflect changes to them. Views are
73
+ shallow, so values are shared with their source. **Proxies do not provide
74
+ security isolation.** Pass a suitable copy or snapshot across trust boundaries.
75
+
76
+ See the [public API and complexity reference](docs/api.md) for operation semantics.
77
+
78
+ To build from source, install a C compiler compatible with your CPython distribution.
79
+ For local development, run `uv sync --frozen` and `uv run pytest`. The editable
80
+ install keeps compiled extensions under `build/`. After changing C sources or
81
+ adding package files, rerun `uv sync --frozen --reinstall-package collex`.
82
+
83
+ Build a wheel and source distribution with `uv build --out-dir build/dist`.
84
+ Run the [container benchmarks](docs/benchmarks.md) with `uv run python benchmarks/containers.py`.
85
+ Linux CI also runs the tests on CPython debug and against native extensions
86
+ built with ASan and UBSan.
87
+ See [native safety and validation](docs/native-safety.md) for the assumptions
88
+ behind the C implementations and the local validation command.
collex-0.1.0/README.md ADDED
@@ -0,0 +1,78 @@
1
+ # collex
2
+
3
+ Containers for CPython 3.15 with the GIL enabled. The development interpreter is
4
+ CPython 3.15.2. Free-threaded CPython and subinterpreters are unsupported.
5
+ The native extensions depend on CPython layouts and are built per minor version.
6
+
7
+ - `OrderedDict` supports inserting and moving entries relative to existing keys.
8
+ - `IdentityDict` and `IdentitySet` compare objects by identity and accept unhashable objects.
9
+ - `KeyedDict` and `KeyedOrderedDict` derive keys from values.
10
+ - `CaseFoldDict`, `FrozenCaseFoldDict`, `CaseFoldSet`, and `FrozenCaseFoldSet` support Unicode case-folded lookups.
11
+ - `SequenceProxy`, `SetProxy`, and `MappingProxy` provide live read-only views of their backing containers.
12
+
13
+ `IdentityDict` uses a compact insertion-ordered identity table. Probing
14
+ compares object pointers directly. The table owns references to both keys and
15
+ values, and its views iterate the entries in place.
16
+
17
+ `IdentitySet` stores one object pointer per table slot and derives the hash
18
+ from that pointer. Probing compares object pointers directly.
19
+ Iteration order is unspecified, and `pop()` removes an arbitrary member.
20
+ Set operators take identity sets, identity keys views, sets, and frozensets on
21
+ the right. The named set operations accept any iterable, with membership matched
22
+ by identity. Comparisons support identity sets and identity keys views. Intersection
23
+ and `isdisjoint()` between identity containers scan the cheaper table where
24
+ both operands expose identity membership.
25
+
26
+ A new `OrderedDict` entry normally goes at the end. Use
27
+ `insert_before(anchor, key, value)` or `insert_after(anchor, key, value)` to choose
28
+ its position. These methods require
29
+ an existing anchor and a new key. Use `move_before(key, anchor)`,
30
+ `move_after(key, anchor)`, or `move_to_end(key, last=False)` to reposition an
31
+ existing entry. The vendored implementation is based on CPython 3.15.2's
32
+ `Objects/odictobject.c`. It is a `dict` subtype and uses an independent hash
33
+ index to find linked-list nodes. Relative positioning takes expected constant
34
+ time, with amortized constant-time insertion.
35
+
36
+ `peek_before(anchor)` and `peek_after(anchor)` return the adjacent key. They
37
+ raise `KeyError` when the anchor or neighbor is missing. `swap(first, second)`
38
+ exchanges the positions of two existing keys. These operations take expected
39
+ constant time. Use `next(iter(mapping))` and `next(reversed(mapping))` for the
40
+ first and last keys.
41
+ Use the ordered mapping's methods to mutate it. Explicit calls such as
42
+ `dict.__setitem__(ordered, key, value)` bypass the linked-list index and are
43
+ unsupported.
44
+
45
+ With `KeyedOrderedDict`, pass only the value after the anchor when inserting.
46
+ The key comes from the configured projection.
47
+
48
+ Mapping views stay live, support reverse iteration, and expose a read-only
49
+ `.mapping` attribute. Keys and items support set comparisons and operations.
50
+ `IdentityDict.keys()` compares with other identity keys views and `IdentitySet`.
51
+ Its set operations match objects by identity and return `IdentitySet`, including
52
+ when keys are unhashable. `IdentityDict.items()` matches keys by identity and
53
+ values by equality. Its set operations return Python sets of hashable pairs.
54
+ Its comparisons support other identity items views.
55
+
56
+ The `.casefolded` property gives direct access to canonical keys or members
57
+ without folding lookups again. Mutable containers expose live read-only proxies.
58
+ Frozen containers expose their immutable `frozendict` or `frozenset` storage.
59
+
60
+ `SetProxy` delegates set operators and comparisons to its backing set.
61
+ Results have the type and semantics supplied by the operands. The proxies
62
+ retain their backing containers and reflect changes to them. Views are
63
+ shallow, so values are shared with their source. **Proxies do not provide
64
+ security isolation.** Pass a suitable copy or snapshot across trust boundaries.
65
+
66
+ See the [public API and complexity reference](docs/api.md) for operation semantics.
67
+
68
+ To build from source, install a C compiler compatible with your CPython distribution.
69
+ For local development, run `uv sync --frozen` and `uv run pytest`. The editable
70
+ install keeps compiled extensions under `build/`. After changing C sources or
71
+ adding package files, rerun `uv sync --frozen --reinstall-package collex`.
72
+
73
+ Build a wheel and source distribution with `uv build --out-dir build/dist`.
74
+ Run the [container benchmarks](docs/benchmarks.md) with `uv run python benchmarks/containers.py`.
75
+ Linux CI also runs the tests on CPython debug and against native extensions
76
+ built with ASan and UBSan.
77
+ See [native safety and validation](docs/native-safety.md) for the assumptions
78
+ behind the C implementations and the local validation command.