Procs
func absToUInt[U: uint | uint8 | uint16](pyInt: PyIntObject; x: var U): bool {. cdecl.}
- Source Edit
func absToUInt[U: uint32 | uint64 | BiggestUInt](pyInt: PyIntObject; x: var U): bool {. cdecl.}
-
EXT. unstable.
ignore signbit. returns false on overflow
Source Edit proc asLongAndOverflow(vv: PyIntObject; ovlf: var bool): int {.inline, ...raises: [], tags: [], forbids: [].}
- PyLong_AsLongAndOverflow Source Edit
proc hash(self: PyIntObject): Hash {.inline, cdecl, ...raises: [], tags: [], forbids: [].}
- Source Edit
proc PyInt_OverflowCType(ctypeName: string): PyOverflowErrorObject {....raises: [], tags: [RootEffect], forbids: [].}
- EXT. used to construct OverflowError of PyLong_As<ctypeName> So no need to call PyLong_AsXxx but toSomeXxInt Source Edit
proc PyLong_AsSize_t(pyInt: PyIntObject; res: var uint): PyOverflowErrorObject {. ...raises: [], tags: [RootEffect], forbids: [].}
- Source Edit
proc PyLong_AsSize_t(v: PyObject; res: var uint): PyBaseErrorObject {. ...raises: [], tags: [RootEffect], forbids: [].}
- Source Edit
proc PyLong_AsSsize_t(v: PyObject; res: var int): PyBaseErrorObject {. ...raises: [], tags: [RootEffect], forbids: [].}
- Source Edit
proc PyLong_AsSsize_t(vv: PyIntObject; res: var int): PyOverflowErrorObject {. ...raises: [], tags: [RootEffect], forbids: [].}
- returns nil if not overflow Source Edit
proc toInt(pyInt: PyIntObject; overflow: var IntSign): int {....raises: [], tags: [], forbids: [].}
- Source Edit
proc toInt(pyInt: PyIntObject; res: var int): bool {....raises: [], tags: [], forbids: [].}
- returns false on overflow (x not_in int.low..int.high) Source Edit
proc toSomeSignedInt[I: SomeSignedInt](pyInt: PyIntObject; overflow: var IntSign): I
-
if overflow, overflow will be IntSign.Negative or IntSign.Positive (depending the sign of the argument) and result be `-1
Otherwise, overflow will be IntSign.Zero
Source Edit proc toSomeSignedIntUnsafe[T: SomeSignedInt](pyInt: PyIntObject): T
- XXX: the caller should take care of overflow It raises OverflowDefect on non-danger build Source Edit
proc toSomeUnsignedInt[U: SomeUnsignedInt](pyInt: PyIntObject; overflow: var IntSign): U
- like toSomeSignedInt<#toInt,PyIntObject,IntSign>_ but for `uint Source Edit
proc toUInt(pyInt: PyIntObject; overflow: var IntSign): uint {....raises: [], tags: [], forbids: [].}
- like toInt<#toInt,PyIntObject,IntSign>_ but for `uint Source Edit
proc toUInt(pyInt: PyIntObject; res: var uint): bool {....raises: [], tags: [], forbids: [].}
- like toInt<#toInt,PyIntObject,int>_ but for `uint Source Edit
Templates
template toIntOrRetOF(vv: PyIntObject): int
- a helper wrapper of PyLong_AsSsize_t return OverflowError for outer function Source Edit
Exports
-
newPyIntSimple, digitPyLong_DECIMAL_BASE, toFloat, frexp, PyIntObject, ofPyIntObject, toFloat, negate, newPyIntFromPtr, newPyInt, newPyInt, setSignNegative, newPyInt, negative, toFloat, pyIntObjectType, zero, newPyInt, newPyIntFromPtr, ofExactPyIntObject, PyLong_DECIMAL_BASE, positive, PyLong_SHIFT, flipSign, PyLong_DECIMAL_SHIFT, numbits, bit_count, bit_length, digitCount, flipSign, setSignNegative, positive, zero, negative, negate, newPyIntSimple, digitPyLong_DECIMAL_BASE, pyIntObjectType, ofPyIntObject, newPyInt, newPyIntFromPtr, newPyInt, newPyIntFromPtr, truncate, PyIntObject, Digit, TwoDigits, newPyInt, newPyInt, ofExactPyIntObject, PyLong_DECIMAL_BASE, SDigit, digitBits, IntSign, PyLong_SHIFT, PyLong_DECIMAL_SHIFT, PY_INT_MAX_STR_DIGITS_THRESHOLD, PY_INT_DEFAULT_MAX_STR_DIGITS