From 63fa338efc6d79662ed25b92edeaa23165f6e990 Mon Sep 17 00:00:00 2001 From: Seungwoo Hong Date: Wed, 27 Dec 2023 10:44:56 +0900 Subject: [PATCH 1/4] feat: add stub file --- pkpy.pyi | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 pkpy.pyi diff --git a/pkpy.pyi b/pkpy.pyi new file mode 100644 index 0000000..1e65986 --- /dev/null +++ b/pkpy.pyi @@ -0,0 +1,2 @@ +def ulid() -> str: + ... \ No newline at end of file From 0dd2302ef35bb602823eaadbf7fccfd116617823 Mon Sep 17 00:00:00 2001 From: Seungwoo Hong Date: Wed, 27 Dec 2023 10:45:04 +0900 Subject: [PATCH 2/4] feat: add python test --- python/tests/__init__.py | 0 python/tests/test.py | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 python/tests/__init__.py create mode 100644 python/tests/test.py diff --git a/python/tests/__init__.py b/python/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/python/tests/test.py b/python/tests/test.py new file mode 100644 index 0000000..61a23e5 --- /dev/null +++ b/python/tests/test.py @@ -0,0 +1,21 @@ +import pkpy +from ulid import microsecond + +if __name__ == '__main__': + import time + + t = time.time() + + for i in range(1000): + a = microsecond.new().str + print(a) + + print(time.time() - t) + + t = time.time() + + for i in range(1000): + a = pkpy.ulid() + print(a) + + print(time.time() - t) From ee8abe5e6f4dffb954e04773308dbc87253f9ad3 Mon Sep 17 00:00:00 2001 From: Seungwoo Hong Date: Wed, 27 Dec 2023 10:45:25 +0900 Subject: [PATCH 3/4] chore: change package version --- Cargo.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 740095c..43d497d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -99,7 +99,7 @@ dependencies = [ [[package]] name = "pkpy" -version = "0.1.0" +version = "0.0.1" dependencies = [ "pyo3", "ulid", From d6d9e4d3c202c6ef538431b24c836502c43e4670 Mon Sep 17 00:00:00 2001 From: Seungwoo Hong Date: Wed, 27 Dec 2023 10:45:33 +0900 Subject: [PATCH 4/4] feat: . --- src/lib.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index da06930..017e58c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,15 +1,14 @@ use pyo3::prelude::*; use ulid::{Ulid}; -/// Formats the sum of two numbers as string. #[pyfunction] -fn test() -> PyResult { +#[pyo3(name="ulid")] +fn get_ulid() -> PyResult { Ok(Ulid::new().to_string()) } -/// A Python module implemented in Rust. #[pymodule] fn pkpy(_py: Python, m: &PyModule) -> PyResult<()> { - m.add_function(wrap_pyfunction!(test, m)?)?; + m.add_function(wrap_pyfunction!(get_ulid, m)?)?; Ok(()) }