File tree 3 files changed +65
-2
lines changed
3 files changed +65
-2
lines changed Original file line number Diff line number Diff line change
1
+ use pyo3:: exceptions:: PyRuntimeWarning ;
2
+ use pyo3:: intern;
1
3
use pyo3:: prelude:: * ;
4
+ use pyo3:: types:: PyTuple ;
2
5
3
6
mod aggregate;
4
7
mod arith;
@@ -17,8 +20,26 @@ fn ___version() -> &'static str {
17
20
VERSION
18
21
}
19
22
23
+ /// Raise RuntimeWarning for debug builds
24
+ #[ pyfunction]
25
+ fn check_debug_build ( py : Python ) -> PyResult < ( ) > {
26
+ #[ cfg( debug_assertions) ]
27
+ {
28
+ let warnings_mod = py. import_bound ( intern ! ( py, "warnings" ) ) ?;
29
+ let warning = PyRuntimeWarning :: new_err (
30
+ "arro3.compute has not been compiled in release mode. Performance will be degraded." ,
31
+ ) ;
32
+ let args = PyTuple :: new_bound ( py, vec ! [ warning. into_py( py) ] ) ;
33
+ warnings_mod. call_method1 ( intern ! ( py, "warn" ) , args) ?;
34
+ }
35
+
36
+ Ok ( ( ) )
37
+ }
38
+
20
39
#[ pymodule]
21
- fn _compute ( _py : Python , m : & Bound < PyModule > ) -> PyResult < ( ) > {
40
+ fn _compute ( py : Python , m : & Bound < PyModule > ) -> PyResult < ( ) > {
41
+ check_debug_build ( py) ?;
42
+
22
43
m. add_wrapped ( wrap_pyfunction ! ( ___version) ) ?;
23
44
24
45
m. add_wrapped ( wrap_pyfunction ! ( aggregate:: max) ) ?;
Original file line number Diff line number Diff line change
1
+ use pyo3:: exceptions:: PyRuntimeWarning ;
2
+ use pyo3:: intern;
1
3
use pyo3:: prelude:: * ;
4
+ use pyo3:: types:: PyTuple ;
2
5
3
6
mod accessors;
4
7
mod constructors;
@@ -10,9 +13,27 @@ fn ___version() -> &'static str {
10
13
VERSION
11
14
}
12
15
16
+ /// Raise RuntimeWarning for debug builds
17
+ #[ pyfunction]
18
+ fn check_debug_build ( py : Python ) -> PyResult < ( ) > {
19
+ #[ cfg( debug_assertions) ]
20
+ {
21
+ let warnings_mod = py. import_bound ( intern ! ( py, "warnings" ) ) ?;
22
+ let warning = PyRuntimeWarning :: new_err (
23
+ "arro3.core has not been compiled in release mode. Performance will be degraded." ,
24
+ ) ;
25
+ let args = PyTuple :: new_bound ( py, vec ! [ warning. into_py( py) ] ) ;
26
+ warnings_mod. call_method1 ( intern ! ( py, "warn" ) , args) ?;
27
+ }
28
+
29
+ Ok ( ( ) )
30
+ }
31
+
13
32
/// A Python module implemented in Rust.
14
33
#[ pymodule]
15
- fn _core ( _py : Python , m : & Bound < PyModule > ) -> PyResult < ( ) > {
34
+ fn _core ( py : Python , m : & Bound < PyModule > ) -> PyResult < ( ) > {
35
+ check_debug_build ( py) ?;
36
+
16
37
m. add_wrapped ( wrap_pyfunction ! ( ___version) ) ?;
17
38
18
39
m. add_class :: < pyo3_arrow:: PyArray > ( ) ?;
Original file line number Diff line number Diff line change
1
+ use pyo3:: exceptions:: PyRuntimeWarning ;
2
+ use pyo3:: intern;
1
3
use pyo3:: prelude:: * ;
4
+ use pyo3:: types:: PyTuple ;
2
5
3
6
mod csv;
4
7
mod error;
@@ -14,8 +17,26 @@ fn ___version() -> &'static str {
14
17
VERSION
15
18
}
16
19
20
+ /// Raise RuntimeWarning for debug builds
21
+ #[ pyfunction]
22
+ fn check_debug_build ( py : Python ) -> PyResult < ( ) > {
23
+ #[ cfg( debug_assertions) ]
24
+ {
25
+ let warnings_mod = py. import_bound ( intern ! ( py, "warnings" ) ) ?;
26
+ let warning = PyRuntimeWarning :: new_err (
27
+ "arro3.io has not been compiled in release mode. Performance will be degraded." ,
28
+ ) ;
29
+ let args = PyTuple :: new_bound ( py, vec ! [ warning. into_py( py) ] ) ;
30
+ warnings_mod. call_method1 ( intern ! ( py, "warn" ) , args) ?;
31
+ }
32
+
33
+ Ok ( ( ) )
34
+ }
35
+
17
36
#[ pymodule]
18
37
fn _io ( py : Python , m : & Bound < PyModule > ) -> PyResult < ( ) > {
38
+ check_debug_build ( py) ?;
39
+
19
40
m. add_wrapped ( wrap_pyfunction ! ( ___version) ) ?;
20
41
21
42
pyo3_object_store:: register_store_module ( py, m, "arro3.io" ) ?;
You can’t perform that action at this time.
0 commit comments