array-api-jit 1.0.0__py3-none-any.whl → 1.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.
array_api_jit/_main.py CHANGED
@@ -19,8 +19,8 @@ if importlib.util.find_spec("numba"):
19
19
  from numba.extending import overload
20
20
 
21
21
  @overload(array_namespace)
22
- def _array_namespace_overload(*args: Any) -> Any:
23
- def inner(*args: Any) -> Any:
22
+ def _array_namespace_overload(*_args: Any) -> Any:
23
+ def inner(*_args: Any) -> Any:
24
24
  return np
25
25
 
26
26
  return inner
@@ -41,6 +41,13 @@ STR_TO_IS_NAMESPACE = {
41
41
  }
42
42
 
43
43
 
44
+ def _identity[**P, T](
45
+ f: Callable[P, T],
46
+ /,
47
+ ) -> Callable[P, T]:
48
+ return f
49
+
50
+
44
51
  def _default_decorator(
45
52
  module: ModuleType,
46
53
  /,
@@ -49,20 +56,19 @@ def _default_decorator(
49
56
  import jax
50
57
 
51
58
  return jax.jit
52
- elif is_numpy_namespace(module) or is_cupy_namespace(module):
59
+ if is_numpy_namespace(module) or is_cupy_namespace(module):
53
60
  # import numba
54
61
 
55
62
  # return numba.jit()
56
63
  # The success rate of numba.jit is low
57
- return lambda x: x
58
- elif is_torch_namespace(module):
64
+ return _identity
65
+ if is_torch_namespace(module):
59
66
  import torch
60
67
 
61
68
  return torch.compile
62
- elif is_dask_namespace(module):
63
- return lambda x: x
64
- else:
65
- return getattr(module, "jit", lambda x: x)
69
+ if is_dask_namespace(module):
70
+ return _identity
71
+ return getattr(module, "jit", _identity)
66
72
 
67
73
 
68
74
  Decorator = Callable[[Callable[Pin, Tin]], Callable[Pin, Tin]]
@@ -120,7 +126,9 @@ def jit(
120
126
 
121
127
  """
122
128
 
123
- def new_decorator(f: Callable[Pinner, Tinner]) -> Callable[Pinner, Tinner]:
129
+ def new_decorator(
130
+ f: Callable[Pinner, Tinner],
131
+ ) -> Callable[Pinner, Tinner]:
124
132
  decorator_args_ = decorator_args or {}
125
133
  decorator_kwargs_ = decorator_kwargs or {}
126
134
  decorator_ = decorator or {}
@@ -130,14 +138,10 @@ def jit(
130
138
  for name_, is_namespace in STR_TO_IS_NAMESPACE.items():
131
139
  if is_namespace(xp):
132
140
  name = name_
133
- else:
134
- name = xp.__name__.split(".")[0]
141
+ name = xp.__name__.split(".")[0]
135
142
  decorator_args__ = decorator_args_.get(name, ())
136
143
  decorator_kwargs__ = decorator_kwargs_.get(name, {})
137
- if name in decorator_:
138
- decorator_current = decorator_[name]
139
- else:
140
- decorator_current = _default_decorator(xp)
144
+ decorator_current = decorator_[name] if name in decorator_ else _default_decorator(xp)
141
145
  try:
142
146
  return decorator_current(f, *decorator_args__, **decorator_kwargs__)
143
147
  except Exception as e:
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: array-api-jit
3
- Version: 1.0.0
3
+ Version: 1.1.0
4
4
  Summary: JIT decorator supporting multiple array API compatible libraries
5
- Author-email: 34j <34j.95a2p@simplelogin.com>
6
- License: MIT
5
+ Author: 34j
6
+ License-Expression: MIT
7
7
  Project-URL: Bug Tracker, https://github.com/34j/array-api-jit/issues
8
8
  Project-URL: Changelog, https://github.com/34j/array-api-jit/blob/main/CHANGELOG.md
9
9
  Project-URL: documentation, https://array-api-jit.readthedocs.io
@@ -12,12 +12,12 @@ Classifier: Development Status :: 2 - Pre-Alpha
12
12
  Classifier: Intended Audience :: Developers
13
13
  Classifier: Natural Language :: English
14
14
  Classifier: Operating System :: OS Independent
15
- Classifier: Programming Language :: Python :: 3.10
16
- Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3 :: Only
17
16
  Classifier: Programming Language :: Python :: 3.12
18
17
  Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Programming Language :: Python :: 3.14
19
19
  Classifier: Topic :: Software Development :: Libraries
20
- Requires-Python: >=3.10
20
+ Requires-Python: >=3.12
21
21
  Description-Content-Type: text/markdown
22
22
  License-File: LICENSE
23
23
  Requires-Dist: array-api-compat>=1.11.2
@@ -32,19 +32,19 @@ Dynamic: license-file
32
32
  <a href="https://array-api-jit.readthedocs.io">
33
33
  <img src="https://img.shields.io/readthedocs/array-api-jit.svg?logo=read-the-docs&logoColor=fff&style=flat-square" alt="Documentation Status">
34
34
  </a>
35
+ </p>
36
+ <p align="center">
35
37
  <a href="https://codecov.io/gh/34j/array-api-jit">
36
38
  <img src="https://img.shields.io/codecov/c/github/34j/array-api-jit.svg?logo=codecov&logoColor=fff&style=flat-square" alt="Test coverage percentage">
37
39
  </a>
38
- </p>
39
- <p align="center">
40
40
  <a href="https://github.com/astral-sh/uv">
41
41
  <img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json" alt="uv">
42
42
  </a>
43
43
  <a href="https://github.com/astral-sh/ruff">
44
44
  <img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json" alt="Ruff">
45
45
  </a>
46
- <a href="https://github.com/pre-commit/pre-commit">
47
- <img src="https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white&style=flat-square" alt="pre-commit">
46
+ <a href="https://github.com/j178/prek">
47
+ <img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/j178/prek/master/docs/assets/badge-v0.json" alt="prek">
48
48
  </a>
49
49
  </p>
50
50
  <p align="center">
@@ -78,6 +78,8 @@ pip install array-api-jit
78
78
  Simply decorate your function with `@jit()`:
79
79
 
80
80
  ```python
81
+ from typing import Any
82
+
81
83
  from array_api_jit import jit
82
84
 
83
85
 
@@ -112,25 +114,3 @@ def sin_n_times(x: Any, n: int) -> Any:
112
114
  x = xp.sin(x)
113
115
  return x
114
116
  ```
115
-
116
- ## Contributors ✨
117
-
118
- Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
119
-
120
- <!-- prettier-ignore-start -->
121
- <!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
122
- <!-- markdownlint-disable -->
123
- <!-- markdownlint-enable -->
124
- <!-- ALL-CONTRIBUTORS-LIST:END -->
125
- <!-- prettier-ignore-end -->
126
-
127
- This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
128
-
129
- ## Credits
130
-
131
- [![Copier](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/copier-org/copier/master/img/badge/badge-grayscale-inverted-border-orange.json)](https://github.com/copier-org/copier)
132
-
133
- This package was created with
134
- [Copier](https://copier.readthedocs.io/) and the
135
- [browniebroke/pypackage-template](https://github.com/browniebroke/pypackage-template)
136
- project template.
@@ -0,0 +1,8 @@
1
+ array_api_jit/__init__.py,sha256=6Cd5sMzZMC4jIJ97HL2eYIS8scDQonRkgK-uT221w_w,64
2
+ array_api_jit/_main.py,sha256=5cjXZOyAl_m1NAE9YNUWD-wORnozj9GUl7gpEpq_UsI,5854
3
+ array_api_jit/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ array_api_jit-1.1.0.dist-info/licenses/LICENSE,sha256=Otwb96xcK4QBqXXVdBKpLZVnc4mJuFTa8rsMUEpphMM,1061
5
+ array_api_jit-1.1.0.dist-info/METADATA,sha256=Bks5iWQ_K91J7ktOSungqKarAt-VeVLHhiHwcGEKM88,4265
6
+ array_api_jit-1.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
7
+ array_api_jit-1.1.0.dist-info/top_level.txt,sha256=90tmkew6kqpBt5VZbfvK2cvsOfCn_oFZfDf74F-s7Hg,14
8
+ array_api_jit-1.1.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.9.0)
2
+ Generator: setuptools (84.2.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,8 +0,0 @@
1
- array_api_jit/__init__.py,sha256=6Cd5sMzZMC4jIJ97HL2eYIS8scDQonRkgK-uT221w_w,64
2
- array_api_jit/_main.py,sha256=RrE4K4y2wO4zukuRrddfBoGrojv8b5XopzMFqh8ftSU,5862
3
- array_api_jit/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- array_api_jit-1.0.0.dist-info/licenses/LICENSE,sha256=Otwb96xcK4QBqXXVdBKpLZVnc4mJuFTa8rsMUEpphMM,1061
5
- array_api_jit-1.0.0.dist-info/METADATA,sha256=9nup4sy6v_xHlno6M6HV4-1ZBCKiGxfINaruINoRnlI,5174
6
- array_api_jit-1.0.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
7
- array_api_jit-1.0.0.dist-info/top_level.txt,sha256=90tmkew6kqpBt5VZbfvK2cvsOfCn_oFZfDf74F-s7Hg,14
8
- array_api_jit-1.0.0.dist-info/RECORD,,