Skip to content

Commit 0f5dc5e

Browse files
committed
Keep machine id lcg seed unmodified on creation
1 parent 860c96f commit 0f5dc5e

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

src/sonyflake_turbo/_sonyflake.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ static PyObject *machine_id_lcg_new(PyTypeObject *type, PyObject *args, PyObject
392392
return NULL;
393393
}
394394

395-
atomic_init(&self->machine_id, machine_id_lcg((uint32_t) seed));
395+
atomic_init(&self->machine_id, seed);
396396

397397
return (PyObject *) self;
398398
}

src/sonyflake_turbo/_sonyflake.pyi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,6 @@ class MachineIDLCG:
5050

5151
def __next__(self) -> int:
5252
"""Produce a Machine ID for :class:`SonyFlake`."""
53+
54+
def __call__(self) -> int:
55+
"""Same as :meth:`__next__`. For usage as a callback."""

tests/test_sonyflake_turbo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,4 @@ def test_machine_id_lcg() -> None:
103103
def test_machine_id_lcg_repr() -> None:
104104
lcg = MachineIDLCG(57243)
105105

106-
assert repr(lcg) == "MachineIDLCG(51966)"
106+
assert repr(lcg) == "MachineIDLCG(57243)"

0 commit comments

Comments
 (0)