numshooter 0.2.1__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.
- numshooter-0.2.1/.gitignore +52 -0
- numshooter-0.2.1/Cargo.lock +180 -0
- numshooter-0.2.1/Cargo.toml +30 -0
- numshooter-0.2.1/LICENSE +21 -0
- numshooter-0.2.1/PKG-INFO +10 -0
- numshooter-0.2.1/README.md +1 -0
- numshooter-0.2.1/pyproject.toml +25 -0
- numshooter-0.2.1/src/functions/basic_ops/mod.rs +58 -0
- numshooter-0.2.1/src/functions/mod.rs +1 -0
- numshooter-0.2.1/src/lib.rs +13 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# --- Rust / Cargo ---
|
|
2
|
+
# O diretório 'target' contém todos os binários e arquivos compilados.
|
|
3
|
+
# É a pasta que mais ocupa espaço (pode chegar a GBs).
|
|
4
|
+
/target/
|
|
5
|
+
|
|
6
|
+
# Arquivos temporários criados pelo Cargo durante a compilação.
|
|
7
|
+
cargo-lock.json
|
|
8
|
+
|
|
9
|
+
# Se você estiver desenvolvendo uma biblioteca (lib), o Cargo.lock
|
|
10
|
+
# geralmente é ignorado. Se for um executável (bin), remova a linha abaixo.
|
|
11
|
+
# Cargo.lock
|
|
12
|
+
|
|
13
|
+
# --- PyO3 / Maturin (Integração Python) ---
|
|
14
|
+
# Pastas criadas pelo maturin ao buildar ou criar wheels
|
|
15
|
+
.maturin/
|
|
16
|
+
dist/
|
|
17
|
+
build/
|
|
18
|
+
*.whl
|
|
19
|
+
|
|
20
|
+
# --- Python (Arquivos de cache e ambiente) ---
|
|
21
|
+
__pycache__/
|
|
22
|
+
*.pyc
|
|
23
|
+
*.pyo
|
|
24
|
+
*.pyd
|
|
25
|
+
.env
|
|
26
|
+
.venv
|
|
27
|
+
env/
|
|
28
|
+
venv/
|
|
29
|
+
.pytest_cache/
|
|
30
|
+
|
|
31
|
+
# --- IDEs ---
|
|
32
|
+
# VS Code
|
|
33
|
+
.vscode/
|
|
34
|
+
!.vscode/settings.json
|
|
35
|
+
!.vscode/tasks.json
|
|
36
|
+
!.vscode/launch.json
|
|
37
|
+
!.vscode/extensions.json
|
|
38
|
+
|
|
39
|
+
# IntelliJ / RustRover
|
|
40
|
+
.idea/
|
|
41
|
+
*.iml
|
|
42
|
+
|
|
43
|
+
# --- Diversos ---
|
|
44
|
+
.DS_Store
|
|
45
|
+
*.swp
|
|
46
|
+
*.bak
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
# Added by cargo
|
|
51
|
+
|
|
52
|
+
/target
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
# This file is automatically @generated by Cargo.
|
|
2
|
+
# It is not intended for manual editing.
|
|
3
|
+
version = 4
|
|
4
|
+
|
|
5
|
+
[[package]]
|
|
6
|
+
name = "autocfg"
|
|
7
|
+
version = "1.5.0"
|
|
8
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
9
|
+
checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"
|
|
10
|
+
|
|
11
|
+
[[package]]
|
|
12
|
+
name = "cfg-if"
|
|
13
|
+
version = "1.0.4"
|
|
14
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
15
|
+
checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
|
|
16
|
+
|
|
17
|
+
[[package]]
|
|
18
|
+
name = "heck"
|
|
19
|
+
version = "0.5.0"
|
|
20
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
21
|
+
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
|
22
|
+
|
|
23
|
+
[[package]]
|
|
24
|
+
name = "indoc"
|
|
25
|
+
version = "2.0.7"
|
|
26
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
27
|
+
checksum = "79cf5c93f93228cf8efb3ba362535fb11199ac548a09ce117c9b1adc3030d706"
|
|
28
|
+
dependencies = [
|
|
29
|
+
"rustversion",
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
[[package]]
|
|
33
|
+
name = "libc"
|
|
34
|
+
version = "0.2.186"
|
|
35
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
36
|
+
checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66"
|
|
37
|
+
|
|
38
|
+
[[package]]
|
|
39
|
+
name = "memoffset"
|
|
40
|
+
version = "0.9.1"
|
|
41
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
42
|
+
checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a"
|
|
43
|
+
dependencies = [
|
|
44
|
+
"autocfg",
|
|
45
|
+
]
|
|
46
|
+
|
|
47
|
+
[[package]]
|
|
48
|
+
name = "numshooter"
|
|
49
|
+
version = "0.1.0"
|
|
50
|
+
dependencies = [
|
|
51
|
+
"pyo3",
|
|
52
|
+
]
|
|
53
|
+
|
|
54
|
+
[[package]]
|
|
55
|
+
name = "once_cell"
|
|
56
|
+
version = "1.21.4"
|
|
57
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
58
|
+
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
|
|
59
|
+
|
|
60
|
+
[[package]]
|
|
61
|
+
name = "portable-atomic"
|
|
62
|
+
version = "1.13.1"
|
|
63
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
64
|
+
checksum = "c33a9471896f1c69cecef8d20cbe2f7accd12527ce60845ff44c153bb2a21b49"
|
|
65
|
+
|
|
66
|
+
[[package]]
|
|
67
|
+
name = "proc-macro2"
|
|
68
|
+
version = "1.0.106"
|
|
69
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
70
|
+
checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934"
|
|
71
|
+
dependencies = [
|
|
72
|
+
"unicode-ident",
|
|
73
|
+
]
|
|
74
|
+
|
|
75
|
+
[[package]]
|
|
76
|
+
name = "pyo3"
|
|
77
|
+
version = "0.23.5"
|
|
78
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
79
|
+
checksum = "7778bffd85cf38175ac1f545509665d0b9b92a198ca7941f131f85f7a4f9a872"
|
|
80
|
+
dependencies = [
|
|
81
|
+
"cfg-if",
|
|
82
|
+
"indoc",
|
|
83
|
+
"libc",
|
|
84
|
+
"memoffset",
|
|
85
|
+
"once_cell",
|
|
86
|
+
"portable-atomic",
|
|
87
|
+
"pyo3-build-config",
|
|
88
|
+
"pyo3-ffi",
|
|
89
|
+
"pyo3-macros",
|
|
90
|
+
"unindent",
|
|
91
|
+
]
|
|
92
|
+
|
|
93
|
+
[[package]]
|
|
94
|
+
name = "pyo3-build-config"
|
|
95
|
+
version = "0.23.5"
|
|
96
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
97
|
+
checksum = "94f6cbe86ef3bf18998d9df6e0f3fc1050a8c5efa409bf712e661a4366e010fb"
|
|
98
|
+
dependencies = [
|
|
99
|
+
"once_cell",
|
|
100
|
+
"target-lexicon",
|
|
101
|
+
]
|
|
102
|
+
|
|
103
|
+
[[package]]
|
|
104
|
+
name = "pyo3-ffi"
|
|
105
|
+
version = "0.23.5"
|
|
106
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
107
|
+
checksum = "e9f1b4c431c0bb1c8fb0a338709859eed0d030ff6daa34368d3b152a63dfdd8d"
|
|
108
|
+
dependencies = [
|
|
109
|
+
"libc",
|
|
110
|
+
"pyo3-build-config",
|
|
111
|
+
]
|
|
112
|
+
|
|
113
|
+
[[package]]
|
|
114
|
+
name = "pyo3-macros"
|
|
115
|
+
version = "0.23.5"
|
|
116
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
117
|
+
checksum = "fbc2201328f63c4710f68abdf653c89d8dbc2858b88c5d88b0ff38a75288a9da"
|
|
118
|
+
dependencies = [
|
|
119
|
+
"proc-macro2",
|
|
120
|
+
"pyo3-macros-backend",
|
|
121
|
+
"quote",
|
|
122
|
+
"syn",
|
|
123
|
+
]
|
|
124
|
+
|
|
125
|
+
[[package]]
|
|
126
|
+
name = "pyo3-macros-backend"
|
|
127
|
+
version = "0.23.5"
|
|
128
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
129
|
+
checksum = "fca6726ad0f3da9c9de093d6f116a93c1a38e417ed73bf138472cf4064f72028"
|
|
130
|
+
dependencies = [
|
|
131
|
+
"heck",
|
|
132
|
+
"proc-macro2",
|
|
133
|
+
"pyo3-build-config",
|
|
134
|
+
"quote",
|
|
135
|
+
"syn",
|
|
136
|
+
]
|
|
137
|
+
|
|
138
|
+
[[package]]
|
|
139
|
+
name = "quote"
|
|
140
|
+
version = "1.0.45"
|
|
141
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
142
|
+
checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924"
|
|
143
|
+
dependencies = [
|
|
144
|
+
"proc-macro2",
|
|
145
|
+
]
|
|
146
|
+
|
|
147
|
+
[[package]]
|
|
148
|
+
name = "rustversion"
|
|
149
|
+
version = "1.0.22"
|
|
150
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
151
|
+
checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
|
|
152
|
+
|
|
153
|
+
[[package]]
|
|
154
|
+
name = "syn"
|
|
155
|
+
version = "2.0.117"
|
|
156
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
157
|
+
checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99"
|
|
158
|
+
dependencies = [
|
|
159
|
+
"proc-macro2",
|
|
160
|
+
"quote",
|
|
161
|
+
"unicode-ident",
|
|
162
|
+
]
|
|
163
|
+
|
|
164
|
+
[[package]]
|
|
165
|
+
name = "target-lexicon"
|
|
166
|
+
version = "0.12.16"
|
|
167
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
168
|
+
checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1"
|
|
169
|
+
|
|
170
|
+
[[package]]
|
|
171
|
+
name = "unicode-ident"
|
|
172
|
+
version = "1.0.24"
|
|
173
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
174
|
+
checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
|
|
175
|
+
|
|
176
|
+
[[package]]
|
|
177
|
+
name = "unindent"
|
|
178
|
+
version = "0.2.4"
|
|
179
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
180
|
+
checksum = "7264e107f553ccae879d21fbea1d6724ac785e8c3bfc762137959b5802826ef3"
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
name = "numshooter"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
authors = ["Eduardo Amorim Pereira <00001200871704sp@al.educacao.sp.gov.br>"]
|
|
5
|
+
edition = "2021"
|
|
6
|
+
description = "A high-performance math engine for Python that... Shoots numbers, literally."
|
|
7
|
+
readme = "README.md"
|
|
8
|
+
license = "MIT"
|
|
9
|
+
repository = "https://github.com/natios-hq/numshooter"
|
|
10
|
+
|
|
11
|
+
[lib]
|
|
12
|
+
# "cdylib" é o segredo para criar bibliotecas que o Python consegue importar
|
|
13
|
+
name = "numshooter"
|
|
14
|
+
crate-type = ["cdylib"]
|
|
15
|
+
|
|
16
|
+
[dependencies]
|
|
17
|
+
pyo3 = { version = "0.23", features = ["extension-module", "abi3"] }
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
[profile.release]
|
|
21
|
+
opt-level = 3
|
|
22
|
+
lto = true
|
|
23
|
+
codegen-units = 1
|
|
24
|
+
panic = "abort"
|
|
25
|
+
strip = true
|
|
26
|
+
|
|
27
|
+
[profile.dev]
|
|
28
|
+
opt-level = 0
|
|
29
|
+
debug = true
|
|
30
|
+
|
numshooter-0.2.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 NATIOS Headquarters
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: numshooter
|
|
3
|
+
Version: 0.2.1
|
|
4
|
+
Classifier: Programming Language :: Rust
|
|
5
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
6
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Summary: A math rifle with high performance written in Rust for Python.
|
|
9
|
+
Author-email: Eduardo Amorim Pereira <00001200871704sp@al.educacao.sp.gov.br>
|
|
10
|
+
Requires-Python: >=3.8
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# numshooter
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["maturin>=1.5,<2.0"]
|
|
3
|
+
build-backend = "maturin"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "numshooter"
|
|
7
|
+
version = "0.2.1"
|
|
8
|
+
description = "A math rifle with high performance written in Rust for Python."
|
|
9
|
+
authors = [
|
|
10
|
+
{ name = "Eduardo Amorim Pereira", email = "00001200871704sp@al.educacao.sp.gov.br" }
|
|
11
|
+
]
|
|
12
|
+
requires-python = ">=3.8"
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Programming Language :: Rust",
|
|
15
|
+
"Programming Language :: Python :: Implementation :: CPython",
|
|
16
|
+
"Topic :: Scientific/Engineering :: Mathematics",
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
[tool.maturin]
|
|
20
|
+
# "extension-module" diz que o Rust vai virar uma biblioteca .so/.pyd que o Python importa
|
|
21
|
+
features = ["pyo3/extension-module"]
|
|
22
|
+
# Otimiza o binário para o seu processador específico (ajuda muito no Termux/ARM)
|
|
23
|
+
rustc-args = ["-C", "target-cpu=native"]
|
|
24
|
+
|
|
25
|
+
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
use pyo3::prelude::*;
|
|
2
|
+
use pyo3::types::PyTuple;
|
|
3
|
+
use pyo3::exceptions::{PyTypeError, PyZeroDivisionError};
|
|
4
|
+
|
|
5
|
+
#[pyfunction(signature = (*args))]
|
|
6
|
+
pub fn add(args: Bound<'_, PyTuple>) -> PyResult<f64> {
|
|
7
|
+
let mut sum = 0.0;
|
|
8
|
+
for arg in args.iter() {
|
|
9
|
+
let val: f64 = arg.extract().map_err(|_| {
|
|
10
|
+
PyTypeError::new_err("Todos os argumentos devem ser numeros")
|
|
11
|
+
})?;
|
|
12
|
+
sum += val;
|
|
13
|
+
}
|
|
14
|
+
Ok(sum)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
#[pyfunction(signature = (*args))]
|
|
18
|
+
pub fn mul(args: Bound<'_, PyTuple>) -> PyResult<f64> {
|
|
19
|
+
if args.is_empty() { return Ok(0.0); }
|
|
20
|
+
let mut res = 1.0;
|
|
21
|
+
for arg in args.iter() {
|
|
22
|
+
let val: f64 = arg.extract().map_err(|_| {
|
|
23
|
+
PyTypeError::new_err("Todos os argumentos devem ser numeros")
|
|
24
|
+
})?;
|
|
25
|
+
res *= val;
|
|
26
|
+
}
|
|
27
|
+
Ok(res)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
#[pyfunction(signature = (*args))]
|
|
31
|
+
pub fn sub(args: Bound<'_, PyTuple>) -> PyResult<f64> {
|
|
32
|
+
if args.is_empty() { return Ok(0.0); }
|
|
33
|
+
let res_first: f64 = args.get_item(0)?.extract()?;
|
|
34
|
+
let mut res = res_first;
|
|
35
|
+
|
|
36
|
+
for i in 1..args.len() {
|
|
37
|
+
let val: f64 = args.get_item(i)?.extract()?;
|
|
38
|
+
res -= val;
|
|
39
|
+
}
|
|
40
|
+
Ok(res)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
#[pyfunction(signature = (*args))]
|
|
44
|
+
pub fn div(args: Bound<'_, PyTuple>) -> PyResult<f64> {
|
|
45
|
+
if args.is_empty() { return Ok(0.0); }
|
|
46
|
+
let res_first: f64 = args.get_item(0)?.extract()?;
|
|
47
|
+
let mut res = res_first;
|
|
48
|
+
|
|
49
|
+
for i in 1..args.len() {
|
|
50
|
+
let val: f64 = args.get_item(i)?.extract()?;
|
|
51
|
+
if val == 0.0 {
|
|
52
|
+
return Err(PyZeroDivisionError::new_err("Divisao por zero detectada"));
|
|
53
|
+
}
|
|
54
|
+
res /= val;
|
|
55
|
+
}
|
|
56
|
+
Ok(res)
|
|
57
|
+
}
|
|
58
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pub mod basic_ops;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
use pyo3::prelude::*;
|
|
2
|
+
|
|
3
|
+
mod functions;
|
|
4
|
+
|
|
5
|
+
#[pymodule]
|
|
6
|
+
fn numshooter(m: &Bound<'_, PyModule>) -> PyResult<()> {
|
|
7
|
+
m.add_function(wrap_pyfunction!(functions::basic_ops::add, m)?)?;
|
|
8
|
+
m.add_function(wrap_pyfunction!(functions::basic_ops::sub, m)?)?;
|
|
9
|
+
m.add_function(wrap_pyfunction!(functions::basic_ops::mul, m)?)?;
|
|
10
|
+
m.add_function(wrap_pyfunction!(functions::basic_ops::div, m)?)?;
|
|
11
|
+
Ok(())
|
|
12
|
+
}
|
|
13
|
+
|