• Dino Viehland's avatar
    bpo-38075: Port _randommodule.c to PEP-384 (GH-15798) · 04f0bbfb
    Dino Viehland authored
    - Migrate `Random_Type` to `PyType_FromSpec`
    - To simulate an old use of `PyLong_Type.tp_as_number->nb_absolute`, I added
      code to the module init function to stash `int.__abs__` for later
      use. Ideally we'd use `PyType_GetSlot()` instead, but it doesn't currently
      work for static types in CPython, and implementing it just for this case
      doesn't seem worth it.
    - Do exact check for long and dispatch to PyNumber_Absolute, use vector call when not exact.
    04f0bbfb
_randommodule.c 17.3 KB