Skip to content

Commit 6f9e9c1

Browse files
committed
feat: bump version to 0.2.0
1 parent 9dbb308 commit 6f9e9c1

3 files changed

Lines changed: 144 additions & 15 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "uuideal"
3-
version = "0.1.0"
3+
version = "0.2.0"
44
edition = "2021"
55
rust-version = "1.75"
66
publish = false

src/lib.rs

Lines changed: 97 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2982,6 +2982,66 @@ unsafe fn restore_all_patches() -> c_int {
29822982
}
29832983
}
29842984

2985+
unsafe extern "C" fn py_uuid1(
2986+
_self: *mut PyObject,
2987+
args: *const *mut PyObject,
2988+
nargs: Py_ssize_t,
2989+
kwnames: *mut PyObject,
2990+
) -> *mut PyObject {
2991+
unsafe {
2992+
if load_uuid_references() < 0 {
2993+
return ptr::null_mut();
2994+
}
2995+
uuid1_vectorcall(ptr::null_mut(), args, nargs as usize, kwnames)
2996+
}
2997+
}
2998+
2999+
unsafe extern "C" fn py_uuid3(
3000+
_self: *mut PyObject,
3001+
args: *const *mut PyObject,
3002+
nargs: Py_ssize_t,
3003+
kwnames: *mut PyObject,
3004+
) -> *mut PyObject {
3005+
unsafe {
3006+
if load_uuid_references() < 0 {
3007+
return ptr::null_mut();
3008+
}
3009+
uuid3_vectorcall(ptr::null_mut(), args, nargs as usize, kwnames)
3010+
}
3011+
}
3012+
3013+
unsafe extern "C" fn py_uuid4(
3014+
_self: *mut PyObject,
3015+
_args: *const *mut PyObject,
3016+
nargs: Py_ssize_t,
3017+
kwnames: *mut PyObject,
3018+
) -> *mut PyObject {
3019+
unsafe {
3020+
if load_uuid_references() < 0 {
3021+
return ptr::null_mut();
3022+
}
3023+
if nargs != 0 || keyword_count(kwnames) != 0 {
3024+
PyErr_SetString(PyExc_TypeError, c"uuid4() takes no arguments".as_ptr());
3025+
return ptr::null_mut();
3026+
}
3027+
allocate_uuid(uuid::Uuid::new_v4().as_u128())
3028+
}
3029+
}
3030+
3031+
unsafe extern "C" fn py_uuid5(
3032+
_self: *mut PyObject,
3033+
args: *const *mut PyObject,
3034+
nargs: Py_ssize_t,
3035+
kwnames: *mut PyObject,
3036+
) -> *mut PyObject {
3037+
unsafe {
3038+
if load_uuid_references() < 0 {
3039+
return ptr::null_mut();
3040+
}
3041+
uuid5_vectorcall(ptr::null_mut(), args, nargs as usize, kwnames)
3042+
}
3043+
}
3044+
29853045
unsafe extern "C" fn py_uuid6(
29863046
_self: *mut PyObject,
29873047
args: *const *mut PyObject,
@@ -3150,7 +3210,7 @@ unsafe fn register_reseed_at_fork() -> c_int {
31503210
}
31513211
}
31523212

3153-
static mut METHODS: [PyMethodDef; 9] = [PyMethodDef::zeroed(); 9];
3213+
static mut METHODS: [PyMethodDef; 12] = [PyMethodDef::zeroed(); 12];
31543214

31553215
unsafe fn init_methods() {
31563216
unsafe {
@@ -3179,38 +3239,70 @@ unsafe fn init_methods() {
31793239
ml_doc: c"Return whether uuid vectorcall patches are installed.".as_ptr(),
31803240
};
31813241
METHODS[3] = PyMethodDef {
3242+
ml_name: c"uuid1".as_ptr(),
3243+
ml_meth: PyMethodDefPointer {
3244+
PyCFunctionFastWithKeywords: py_uuid1,
3245+
},
3246+
ml_flags: METH_FASTCALL | METH_KEYWORDS,
3247+
ml_doc: c"Generate a version 1 UUID.".as_ptr(),
3248+
};
3249+
METHODS[4] = PyMethodDef {
3250+
ml_name: c"uuid3".as_ptr(),
3251+
ml_meth: PyMethodDefPointer {
3252+
PyCFunctionFastWithKeywords: py_uuid3,
3253+
},
3254+
ml_flags: METH_FASTCALL | METH_KEYWORDS,
3255+
ml_doc: c"Generate a version 3 UUID.".as_ptr(),
3256+
};
3257+
METHODS[5] = PyMethodDef {
3258+
ml_name: c"uuid4".as_ptr(),
3259+
ml_meth: PyMethodDefPointer {
3260+
PyCFunctionFastWithKeywords: py_uuid4,
3261+
},
3262+
ml_flags: METH_FASTCALL | METH_KEYWORDS,
3263+
ml_doc: c"Generate a version 4 UUID.".as_ptr(),
3264+
};
3265+
METHODS[6] = PyMethodDef {
3266+
ml_name: c"uuid5".as_ptr(),
3267+
ml_meth: PyMethodDefPointer {
3268+
PyCFunctionFastWithKeywords: py_uuid5,
3269+
},
3270+
ml_flags: METH_FASTCALL | METH_KEYWORDS,
3271+
ml_doc: c"Generate a version 5 UUID.".as_ptr(),
3272+
};
3273+
METHODS[7] = PyMethodDef {
31823274
ml_name: c"uuid6".as_ptr(),
31833275
ml_meth: PyMethodDefPointer {
31843276
PyCFunctionFastWithKeywords: py_uuid6,
31853277
},
31863278
ml_flags: METH_FASTCALL | METH_KEYWORDS,
31873279
ml_doc: c"Generate a version 6 UUID.".as_ptr(),
31883280
};
3189-
METHODS[4] = PyMethodDef {
3281+
METHODS[8] = PyMethodDef {
31903282
ml_name: c"uuid7".as_ptr(),
31913283
ml_meth: PyMethodDefPointer {
31923284
PyCFunctionFastWithKeywords: py_uuid7,
31933285
},
31943286
ml_flags: METH_FASTCALL | METH_KEYWORDS,
31953287
ml_doc: c"Generate a version 7 UUID.".as_ptr(),
31963288
};
3197-
METHODS[5] = PyMethodDef {
3289+
METHODS[9] = PyMethodDef {
31983290
ml_name: c"uuid8".as_ptr(),
31993291
ml_meth: PyMethodDefPointer {
32003292
PyCFunctionFastWithKeywords: py_uuid8,
32013293
},
32023294
ml_flags: METH_FASTCALL | METH_KEYWORDS,
32033295
ml_doc: c"Generate a version 8 UUID.".as_ptr(),
32043296
};
3205-
METHODS[6] = PyMethodDef {
3297+
METHODS[10] = PyMethodDef {
32063298
ml_name: c"reseed_rng".as_ptr(),
32073299
ml_meth: PyMethodDefPointer {
32083300
PyCFunction: py_reseed_rng,
32093301
},
32103302
ml_flags: METH_NOARGS,
32113303
ml_doc: c"Reseed the Rust random number generator.".as_ptr(),
32123304
};
3213-
METHODS[8] = PyMethodDef::zeroed();
3305+
METHODS[11] = PyMethodDef::zeroed();
32143306
}
32153307
}
32163308

uuideal/__init__.pyi

Lines changed: 46 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,48 @@
11
from uuid import UUID
22

3-
__all__ = ["install", "uninstall", "installed", "uuid6", "uuid7", "uuid8"]
4-
5-
def install() -> None: ...
6-
def uninstall() -> None: ...
7-
def installed() -> bool: ...
8-
def uuid6(node: int | None = None, clock_seq: int | None = None) -> UUID: ...
9-
def uuid7() -> UUID: ...
10-
def uuid8(a: int | None = None, b: int | None = None, c: int | None = None) -> UUID: ...
11-
def reseed_rng() -> None: ...
3+
__all__ = [
4+
"install",
5+
"uninstall",
6+
"installed",
7+
"uuid1",
8+
"uuid3",
9+
"uuid4",
10+
"uuid5",
11+
"uuid6",
12+
"uuid7",
13+
"uuid8",
14+
"reseed_rng",
15+
]
16+
17+
def install() -> None:
18+
"""Install vectorcall patches that accelerate stdlib uuid functions and UUID methods"""
19+
20+
def uninstall() -> None:
21+
"""Uninstall vectorcall patches and restore stdlib uuid function and UUID method behavior"""
22+
23+
def installed() -> bool:
24+
"""Return whether uuideal vectorcall patches are currently installed"""
25+
26+
def uuid1(node: int | None = None, clock_seq: int | None = None) -> UUID:
27+
"""Generate a version 1 UUID without installing global uuid module patches"""
28+
29+
def uuid3(namespace: UUID, name: str | bytes) -> UUID:
30+
"""Generate a version 3 UUID without installing global uuid module patches"""
31+
32+
def uuid4() -> UUID:
33+
"""Generate a version 4 UUID without installing global uuid module patches"""
34+
35+
def uuid5(namespace: UUID, name: str | bytes) -> UUID:
36+
"""Generate a version 5 UUID without installing global uuid module patches"""
37+
38+
def uuid6(node: int | None = None, clock_seq: int | None = None) -> UUID:
39+
"""Generate a version 6 UUID without installing global uuid module patches."""
40+
41+
def uuid7() -> UUID:
42+
"""Generate a version 7 UUID without installing global uuid module patches."""
43+
44+
def uuid8(a: int | None = None, b: int | None = None, c: int | None = None) -> UUID:
45+
"""Generate a version 8 UUID without installing global uuid module patches."""
46+
47+
def reseed_rng() -> None:
48+
"""Reseed the Rust random number generator used by uuideal."""

0 commit comments

Comments
 (0)