gc-primitives 0.1.0__py3-none-any.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.
- gc_primitives/__init__.py +14 -0
- gc_primitives/_pool.py +166 -0
- gc_primitives-0.1.0.dist-info/METADATA +116 -0
- gc_primitives-0.1.0.dist-info/RECORD +7 -0
- gc_primitives-0.1.0.dist-info/WHEEL +5 -0
- gc_primitives-0.1.0.dist-info/licenses/LICENSE +201 -0
- gc_primitives-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"""gc-primitives · 减少分配与复用的 Python 语义移植。
|
|
2
|
+
|
|
3
|
+
规范见仓库根 SPEC.md。纯 Python 实现,**不承诺性能收益**,价值在跨语言契约一致。
|
|
4
|
+
|
|
5
|
+
from gc_primitives import Pool
|
|
6
|
+
|
|
7
|
+
pool = Pool(list, list.clear)
|
|
8
|
+
with pool.borrow() as xs:
|
|
9
|
+
xs.append(1)
|
|
10
|
+
"""
|
|
11
|
+
from ._pool import Lease, Pool, PoolStateError, noop_recycler
|
|
12
|
+
|
|
13
|
+
__all__ = ["Pool", "Lease", "PoolStateError", "noop_recycler"]
|
|
14
|
+
__version__ = "0.1.0"
|
gc_primitives/_pool.py
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
"""gc-primitives · 纯 Python 语义移植。
|
|
2
|
+
|
|
3
|
+
行为规范见仓库根 SPEC.md。定位是**跨语言契约一致性**,不承诺比 CPython 解释器快:
|
|
4
|
+
CPython 主力是引用计数,另有分代 GC 清循环引用,再加 pymalloc 的 arena 与小对象
|
|
5
|
+
free-list,解释器底层已经在做复用,纯 Python 再手写一层对象池常与内置缓存重叠。
|
|
6
|
+
|
|
7
|
+
契约要点:
|
|
8
|
+
- 用 ``with pool.borrow() as x`` 显式归还(对应 Java 的 try-with-resources);
|
|
9
|
+
- 句柄与对象只归借用线程使用,跨线程归还/取用抛 PoolStateError;
|
|
10
|
+
- 每线程空闲对象数有上限,超出直接丢弃;
|
|
11
|
+
- 归还时由库调用 recycler 复位;复位失败则**对象丢弃、绝不回池**;
|
|
12
|
+
- 误用始终强制校验,不设开关。
|
|
13
|
+
"""
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
import threading
|
|
17
|
+
from typing import Any, Callable, Generic, List, Optional, TypeVar
|
|
18
|
+
|
|
19
|
+
T = TypeVar("T")
|
|
20
|
+
|
|
21
|
+
__all__ = ["Pool", "Lease", "PoolStateError", "noop_recycler"]
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class PoolStateError(RuntimeError):
|
|
25
|
+
"""池契约被破坏时抛出;对应 Java 的 PoolStateException / C++ 的 pool_error。"""
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def noop_recycler(value: Any) -> None:
|
|
29
|
+
"""不做任何复位的复位钩子,适用于无可变状态的对象。"""
|
|
30
|
+
return None
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class Lease(Generic[T]):
|
|
34
|
+
"""一次借用的句柄,配合 ``with`` 使用。"""
|
|
35
|
+
|
|
36
|
+
__slots__ = ("_pool", "_value", "_borrower", "_active")
|
|
37
|
+
|
|
38
|
+
def __init__(self, pool: "Pool[T]", value: T, borrower: int) -> None:
|
|
39
|
+
self._pool: Pool[T] = pool
|
|
40
|
+
self._value: Optional[T] = value
|
|
41
|
+
self._borrower = borrower
|
|
42
|
+
self._active = True
|
|
43
|
+
|
|
44
|
+
def get(self) -> T:
|
|
45
|
+
if not self._active:
|
|
46
|
+
raise PoolStateError("lease is closed; get() after close()")
|
|
47
|
+
if threading.get_ident() != self._borrower:
|
|
48
|
+
raise PoolStateError("lease used off its borrowing thread")
|
|
49
|
+
return self._value # type: ignore[return-value]
|
|
50
|
+
|
|
51
|
+
def close(self) -> None:
|
|
52
|
+
"""显式归还;重复关闭或跨线程关闭抛 PoolStateError。"""
|
|
53
|
+
if not self._active:
|
|
54
|
+
raise PoolStateError("lease already returned (double close)")
|
|
55
|
+
if threading.get_ident() != self._borrower:
|
|
56
|
+
raise PoolStateError("cross-thread return")
|
|
57
|
+
|
|
58
|
+
self._active = False
|
|
59
|
+
value = self._value
|
|
60
|
+
self._value = None
|
|
61
|
+
# 复位失败时 _return 会照常抛异常,但对象不回池;租约此时已失效
|
|
62
|
+
self._pool._return(value)
|
|
63
|
+
|
|
64
|
+
def __enter__(self) -> T:
|
|
65
|
+
return self.get()
|
|
66
|
+
|
|
67
|
+
def __exit__(self, exc_type: Any, exc: Any, tb: Any) -> bool:
|
|
68
|
+
# 即使 with 体内抛异常,也要归还(并让原异常继续冒泡)
|
|
69
|
+
self.close()
|
|
70
|
+
return False
|
|
71
|
+
|
|
72
|
+
@property
|
|
73
|
+
def active(self) -> bool:
|
|
74
|
+
return self._active
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
class Pool(Generic[T]):
|
|
78
|
+
"""全局对象内含线程本地状态:一个 Pool 实例可跨线程使用,每线程各自一份有界空闲栈。"""
|
|
79
|
+
|
|
80
|
+
DEFAULT_CAPACITY = 64
|
|
81
|
+
|
|
82
|
+
def __init__(
|
|
83
|
+
self,
|
|
84
|
+
factory: Callable[[], T],
|
|
85
|
+
recycler: Optional[Callable[[T], Any]] = None,
|
|
86
|
+
capacity: int = DEFAULT_CAPACITY,
|
|
87
|
+
) -> None:
|
|
88
|
+
if capacity <= 0:
|
|
89
|
+
raise ValueError("capacity must be > 0")
|
|
90
|
+
self._factory = factory
|
|
91
|
+
self._recycler: Callable[[T], Any] = recycler or noop_recycler
|
|
92
|
+
self._capacity = capacity
|
|
93
|
+
self._local = threading.local()
|
|
94
|
+
self._lock = threading.Lock()
|
|
95
|
+
self._borrows = 0
|
|
96
|
+
self._returns = 0
|
|
97
|
+
self._live = 0
|
|
98
|
+
|
|
99
|
+
def borrow(self) -> Lease[T]:
|
|
100
|
+
state = self._state(create=True)
|
|
101
|
+
if state:
|
|
102
|
+
value = state.pop()
|
|
103
|
+
else:
|
|
104
|
+
value = self._factory()
|
|
105
|
+
if value is None:
|
|
106
|
+
raise PoolStateError("factory returned None")
|
|
107
|
+
with self._lock:
|
|
108
|
+
self._borrows += 1
|
|
109
|
+
self._live += 1
|
|
110
|
+
return Lease(self, value, threading.get_ident())
|
|
111
|
+
|
|
112
|
+
def capacity(self) -> int:
|
|
113
|
+
return self._capacity
|
|
114
|
+
|
|
115
|
+
def idle_count(self) -> int:
|
|
116
|
+
"""当前线程的空闲对象数;仅用于诊断。"""
|
|
117
|
+
return len(self._state(create=False))
|
|
118
|
+
|
|
119
|
+
def active_leases(self) -> int:
|
|
120
|
+
with self._lock:
|
|
121
|
+
return self._live
|
|
122
|
+
|
|
123
|
+
def borrow_count(self) -> int:
|
|
124
|
+
with self._lock:
|
|
125
|
+
return self._borrows
|
|
126
|
+
|
|
127
|
+
def return_count(self) -> int:
|
|
128
|
+
with self._lock:
|
|
129
|
+
return self._returns
|
|
130
|
+
|
|
131
|
+
def assert_no_active_leases(self) -> None:
|
|
132
|
+
n = self.active_leases()
|
|
133
|
+
if n != 0:
|
|
134
|
+
raise PoolStateError(
|
|
135
|
+
f"{n} lease(s) not returned; use 'with pool.borrow() as x'"
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
# ---- 内部 ----
|
|
139
|
+
|
|
140
|
+
def _state(self, create: bool) -> List[T]:
|
|
141
|
+
values: Optional[List[T]] = getattr(self._local, "values", None)
|
|
142
|
+
if values is None:
|
|
143
|
+
if not create:
|
|
144
|
+
return []
|
|
145
|
+
values = []
|
|
146
|
+
self._local.values = values
|
|
147
|
+
return values
|
|
148
|
+
|
|
149
|
+
def _return(self, value: Optional[T]) -> None:
|
|
150
|
+
try:
|
|
151
|
+
self._recycler(value) # type: ignore[arg-type]
|
|
152
|
+
except BaseException:
|
|
153
|
+
# 复位失败:对象直接丢弃,计数照常结算,租约已失效,污染不得入池
|
|
154
|
+
with self._lock:
|
|
155
|
+
self._returns += 1
|
|
156
|
+
self._live -= 1
|
|
157
|
+
raise
|
|
158
|
+
|
|
159
|
+
with self._lock:
|
|
160
|
+
self._returns += 1
|
|
161
|
+
self._live -= 1
|
|
162
|
+
|
|
163
|
+
state = self._state(create=False)
|
|
164
|
+
if len(state) < self._capacity:
|
|
165
|
+
state.append(value) # type: ignore[arg-type]
|
|
166
|
+
# 超出上限直接丢弃,由引用计数回收,保证有界
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: gc-primitives
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Allocation-reducing object pooling primitives (Python semantic port of the cross-language spec)
|
|
5
|
+
Author-email: rainbowcrr-sys <rainbowcrr.sys@gmail.com>
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/rainbowcrr-sys/rbc-monorepo
|
|
8
|
+
Project-URL: Repository, https://github.com/rainbowcrr-sys/rbc-monorepo
|
|
9
|
+
Project-URL: Specification, https://github.com/rainbowcrr-sys/rbc-monorepo/blob/main/SPEC.md
|
|
10
|
+
Keywords: object-pool,allocation,zero-dependency,gc-primitives
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
20
|
+
Requires-Python: >=3.9
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Dynamic: license-file
|
|
24
|
+
|
|
25
|
+
# gc-primitives · Python 版
|
|
26
|
+
|
|
27
|
+
> 中文 · [English](README.en.md)
|
|
28
|
+
|
|
29
|
+
与 Java / C++ 版同一套概念契约的纯 Python 语义移植,行为规范见仓库根 [SPEC.md](../SPEC.md)([English](../SPEC.en.md))。
|
|
30
|
+
|
|
31
|
+
> **不承诺性能收益。** 这一版的定位是跨语言契约一致性、语义清晰与教学对照,
|
|
32
|
+
> 不是「比解释器快」。原因见下。
|
|
33
|
+
|
|
34
|
+
## 为什么纯 Python 对象池不承诺加速
|
|
35
|
+
|
|
36
|
+
CPython 主力是**引用计数**:每个对象记着被谁指着,引用归零立刻就地释放,根本不攒着等 GC;
|
|
37
|
+
另外才挂了一个**分代 GC**,专门清引用计数搞不定的循环引用(A 指 B、B 指 A)。
|
|
38
|
+
再加上 pymalloc 的 arena 和小对象 free-list(`list` / `dict` / `float` 等解释器自己就池化),
|
|
39
|
+
底层已经在做复用了。纯 Python 再手写一层对象池,常常只是和内置缓存重叠,
|
|
40
|
+
甚至因为多一层 Python 函数调用更慢。
|
|
41
|
+
|
|
42
|
+
所以这一版的价值是:**同一套契约在第三个语言里也成立**,以及能跟 Java / C++ 版逐条对照。
|
|
43
|
+
|
|
44
|
+
## 导入
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
from gc_primitives import Pool
|
|
48
|
+
|
|
49
|
+
pool = Pool(list, list.clear, capacity=8) # factory, recycler, capacity
|
|
50
|
+
|
|
51
|
+
with pool.borrow() as xs:
|
|
52
|
+
xs.append("hello")
|
|
53
|
+
# __exit__ 自动归还,list.clear 在这里把对象复位
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
`with pool.borrow() as x` 对应 Java 的 try-with-resources 与 C++ 的 RAII 析构。
|
|
57
|
+
**必须显式用 `with`(或显式 `lease.close()`)**,Python 版不做析构兜底自动归还。
|
|
58
|
+
|
|
59
|
+
无状态对象可以省掉复位钩子:
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
from gc_primitives import Pool, noop_recycler
|
|
63
|
+
|
|
64
|
+
pool = Pool(object, noop_recycler) # 也可直接省略 recycler 参数
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## API 对照(snake_case 对齐语义,不照搬 camelCase)
|
|
68
|
+
|
|
69
|
+
| Java | C++ | Python |
|
|
70
|
+
| --- | --- | --- |
|
|
71
|
+
| `Pool<T>` / `Pools.threadLocal(...)` | `rbc::gc::Pool<T, F, R>` | `Pool` |
|
|
72
|
+
| `Lease<T>` | `Pool::Lease` | `Lease` |
|
|
73
|
+
| `Recycler<T>` / `Supplier<T>` | 模板参数 `Recycler` / `Factory` | `recycler` / `factory` 可调用对象 |
|
|
74
|
+
| `PoolStateException` | `pool_error` | `PoolStateError` |
|
|
75
|
+
| `borrow()` | `borrow()` | `borrow()` |
|
|
76
|
+
| `capacity()` / `idleCount()` | `capacity()` / `idle_count()` | `capacity()` / `idle_count()` |
|
|
77
|
+
| `activeLeases()` | `active_leases()` | `active_leases()` |
|
|
78
|
+
| `borrowCount()` / `returnCount()` | `borrow_count()` / `return_count()` | `borrow_count()` / `return_count()` |
|
|
79
|
+
| `assertNoActiveLeases()` | `assert_no_active_leases()` | `assert_no_active_leases()` |
|
|
80
|
+
|
|
81
|
+
## 契约细则(Python 特有)
|
|
82
|
+
|
|
83
|
+
- **并发用 `threading.local` 有界栈**,只保证线程隔离。
|
|
84
|
+
⚠️ **asyncio 同一线程内的多个任务不隔离**:协程切换不会触发线程切换,
|
|
85
|
+
本库不会识别任务边界。需要任务级隔离请自己按 task 分 Pool,或等后续 ContextVar 方案。
|
|
86
|
+
- **复位失败**:异常照常抛出,但**对象直接丢弃、绝不回池**,租约仍然失效,计数照常结算。
|
|
87
|
+
不像 Java/C++ 那样约定「复位不抛」——Python 没有 `noexcept`,因此选择在契约层隔离污染。
|
|
88
|
+
- **`factory` 返回 `None`** 即抛 `PoolStateError`;`capacity <= 0` 抛 `ValueError`。
|
|
89
|
+
- **误用始终强制校验**:双重归还、跨线程归还/取用、关闭后 `get()` 全抛 `PoolStateError`。
|
|
90
|
+
- 不拦截「归还后仍被外部引用」——`close()` 之后不得再持有 `with ... as x` 拿到的对象。
|
|
91
|
+
|
|
92
|
+
## 测试
|
|
93
|
+
|
|
94
|
+
只用标准库 `unittest`,无需安装任何依赖:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
python3 -m unittest discover -s python/tests -v
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
14 项契约测试与 Java / C++ 版逐条对应,额外覆盖 `with` 体内抛异常仍归还、复位失败丢弃对象。
|
|
101
|
+
|
|
102
|
+
## 分发
|
|
103
|
+
|
|
104
|
+
PyPI:`gc-primitives`,导入名 `gc_primitives`,Python 3.9+,Apache-2.0,版本 `0.1.0`。
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
pip install gc-primitives
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
打包:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
cd python && python3 -m build
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
版本与 Java / C++ 各自独立,不被已发布的 Java `0.1.0` 锁住。
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
gc_primitives/__init__.py,sha256=ikfY1TxwX3g0-cRJf6AZ52p4-fqAcqfoE5uSOcXOGMU,454
|
|
2
|
+
gc_primitives/_pool.py,sha256=33-ToYDDCRo0nnW9-u1lTlaYkRCcsNkYPxneu9XerjI,5632
|
|
3
|
+
gc_primitives-0.1.0.dist-info/licenses/LICENSE,sha256=6QexHxP6iua3HAEMlGxDFa5FRYNAzeLQaaId49D17Vo,11344
|
|
4
|
+
gc_primitives-0.1.0.dist-info/METADATA,sha256=917VWQuJ_cTeRhXul1QDW0XwzKH_KJL_58rRm7_-p1E,5023
|
|
5
|
+
gc_primitives-0.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
6
|
+
gc_primitives-0.1.0.dist-info/top_level.txt,sha256=ekx66NyKU7sAxt_p4z5CJghk3PqDT5RLbgZIfKHXYus,14
|
|
7
|
+
gc_primitives-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 rainbowcrr-sys
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
gc_primitives
|