Class: int_

Sk.builtin.int_(xnon-null, baseopt, non-null) → {Sk.builtin.int_|Sk.builtin.lng}

new int_(xnon-null, baseopt, non-null) → {Sk.builtin.int_|Sk.builtin.lng}

Constructor for Python int. If provided number is greater than integer threshold, will return a Python long instead.

type int, all integers are created with this method, it is also used for the builtin int()

Takes also implemented __int__ and __trunc__ methods for x into account and tries to use __index__ and/or __int__ if base is not a number

Parameters:
Name Type Attributes Description
x Object | number

Python object or Javascript number to convert to Python int

base Object | number | Sk.builtin.none <optional>

Optional base, can only be used when x is Sk.builtin.str

Source:
Returns:

Python int (or long, if overflow)

Type
Sk.builtin.int_ | Sk.builtin.lng

Extends

Members

(static) threshold$ :number

Threshold to determine when types should be converted to long.

Note: be sure to check against threshold in both positive and negative directions.

Type:
  • number
Source:

$r

Return the string representation of this instance.

Javascript function, returns Python object.

Inherited From:
Source:

__abs__

Python wrapper of __abs__ method.

Inherited From:
Source:

__add__

Python wrapper of __add__ method.

Inherited From:
Source:

__coerce__

Python wrapper of __coerce__ method.

Inherited From:
Source:

__complex__

Python wrapper of __complex__ dunder method.

Source:

__div__

Python wrapper of __div__ method.

Inherited From:
Source:

__divmod__

Python wrapper of __divmod__ method.

Inherited From:
Source:

__eq__

Python wrapper for __eq__ method.

Inherited From:
Source:

__float__

Python wrapper of __float__ method.

Inherited From:
Source:

__floordiv__

Python wrapper of __floordiv__ method.

Inherited From:
Source:

__ge__

Python wrapper for __ge__ method.

Inherited From:
Source:

__gt__

Python wrapper for __gt__ method.

Inherited From:
Source:

__hash__

Python wrapper for __hash__ method.

Inherited From:
Source:

__index__

Python wrapper of __index__ dunder method.

Source:

__int__

Python wrapper of __int__ method.

Inherited From:
Source:

__le__

Python wrapper for __le__ method.

Inherited From:
Source:

__long__

Python wrapper of __long__ method.

Inherited From:
Source:

__lt__

Python wrapper for __lt__ method.

Inherited From:
Source:

__mod__

Python wrapper of __mod__ method.

Inherited From:
Source:

__mul__

Python wrapper of __mul__ method.

Inherited From:
Source:

__ne__

Python wrapper for __ne__ method.

Inherited From:
Source:

__neg__

Python wrapper of __neg__ method.

Inherited From:
Source:

__new__

Default implementation of new just calls the class constructor

Inherited From:
Source:

__pos__

Python wrapper of __pos__ method.

Inherited From:
Source:

__pow__

Python wrapper of __pow__ method.

Inherited From:
Source:

__radd__

Python wrapper of __radd__ method.

Inherited From:
Source:

__rdiv__

Python wrapper of __rdiv__ method.

Inherited From:
Source:

__rdivmod__

Python wrapper of __rdivmod__ method.

Inherited From:
Source:

__repr__

Python wrapper for __repr__ method.

Inherited From:
Source:

__rfloordiv__

Python wrapper of __rfloordiv__ method.

Inherited From:
Source:

__rmod__

Python wrapper of __rmod__ method.

Inherited From:
Source:

__rmul__

Python wrapper of __rmul__ method.

Inherited From:
Source:

__rpow__

Python wrapper of __rpow__ method.

Inherited From:
Source:

__rsub__

Python wrapper of __rsub__ method.

Inherited From:
Source:

__str__

Python wrapper for __str__ method.

Inherited From:
Source:

__sub__

Python wrapper of __sub__ method.

Inherited From:
Source:

__trunc__

Python wrapper of __trunc__ dunder method.

Source:

nb$inplace_add

Source:

nb$inplace_divide

Source:

nb$inplace_floor_divide

Source:

nb$inplace_multiply

Source:

nb$inplace_power

Source:

nb$inplace_remainder

Source:

nb$inplace_subtract

Source:

ob$type :Sk.builtin.type|Object

The type object of this class.

Type:
  • Sk.builtin.type | Object
Inherited From:
Source:

tp$name :string

The name of this class.

Type:
  • string
Inherited From:
Source:

Methods

"$r"()

Source:

clone() → {Sk.builtin.int_}

Returns a copy of this instance.

Javascript function, returns Python object.

Source:
Returns:

The copy

Type
Sk.builtin.int_

GenericGetAttr(pyName, canSuspendopt) → {undefined}

Get an attribute

Parameters:
Name Type Attributes Description
pyName Object

Python string name of the attribute

canSuspend boolean <optional>

Can we return a suspension?

Inherited From:
Source:
Returns:
Type
undefined

GenericSetAttr(pyName, value, canSuspendopt) → {undefined}

Parameters:
Name Type Attributes Description
pyName Object
value Object
canSuspend boolean <optional>
Inherited From:
Source:
Returns:
Type
undefined

nb$abs() → {Sk.builtin.numtype|Sk.builtin.NotImplemented}

Compute the absolute value of this instance and return.

Javascript function, returns Python object.

Overrides:
Source:
Returns:

The absolute value

Type
Sk.builtin.numtype | Sk.builtin.NotImplemented

nb$add(othernon-null) → {Sk.builtin.numtype|Sk.builtin.NotImplemented}

Add a Python object to this instance and return the result (i.e. this + other).

Returns NotImplemented if addition between this type and other type is unsupported.

Javscript function, returns Python object.

Parameters:
Name Type Description
other Sk.builtin.object

The Python object to add.

Overrides:
Source:
Returns:

The result of the addition.

Type
Sk.builtin.numtype | Sk.builtin.NotImplemented

nb$and(othernon-null) → {Sk.builtin.int_|Sk.builtin.lng|Sk.builtin.NotImplemented}

Compute the bitwise AND of this instance and a Python object (i.e. this & other).

Returns NotImplemented if bitwise AND operation between int and other type is unsupported.

Javscript function, returns Python object.

Parameters:
Name Type Description
other Sk.builtin.object

The Python object to AND with this one

Source:
Returns:

The result of the conjunction

Type
Sk.builtin.int_ | Sk.builtin.lng | Sk.builtin.NotImplemented

nb$divide(othernon-null) → {Sk.builtin.numtype|Sk.builtin.NotImplemented}

Divide this instance by a Python object and return the result (i.e this / other).

Returns NotImplemented if division between this type and other type is unsupported.

Javscript function, returns Python object.

Parameters:
Name Type Description
other Sk.builtin.object

The divisor, which must be a Python object.

Overrides:
Source:
Returns:

The result of the division

Type
Sk.builtin.numtype | Sk.builtin.NotImplemented

nb$divmod(othernon-null) → {Sk.builtin.tuple|Sk.builtin.NotImplemented}

Compute the quotient and the remainder of this instance and a given Python object and return the result.

Returns NotImplemented if division or modulo operations between this type and other type are unsupported.

Javscript function, returns Python object.

Parameters:
Name Type Description
other Sk.builtin.object

The divisor, which must be a Python object.

Overrides:
Source:
Returns:

The result of the operation. If both operations are supported, a Python tuple containing (quotient, remainder) in that order.

Type
Sk.builtin.tuple | Sk.builtin.NotImplemented

nb$floor_divide(othernon-null) → {Sk.builtin.numtype|Sk.builtin.NotImplemented}

Floor divide this instance by a Python object and return the result (i.e. this // other).

Returns NotImplemented if floor division between this type and other type is unsupported.

Javscript function, returns Python object.

Parameters:
Name Type Description
other Sk.builtin.object

The divisor, which must be a Python object.

Overrides:
Source:
Returns:

The result of the floor division

Type
Sk.builtin.numtype | Sk.builtin.NotImplemented

nb$inplace_and(othernon-null) → {Sk.builtin.int_|Sk.builtin.lng|Sk.builtin.NotImplemented}

Compute the bitwise AND of this instance and a Python object (i.e. this &= other).

Returns NotImplemented if inplace bitwise AND operation between int and other type is unsupported.

Javscript function, returns Python object.

Parameters:
Name Type Description
other Sk.builtin.object

The Python object to AND with this one

Source:
Returns:

The result of the conjunction

Type
Sk.builtin.int_ | Sk.builtin.lng | Sk.builtin.NotImplemented

nb$inplace_lshift(othernon-null) → {Sk.builtin.int_|Sk.builtin.lng|Sk.builtin.NotImplemented}

Compute the bitwise left shift of this instance by a Python object (i.e. this <<= other).

Returns NotImplemented if inplace bitwise left shift operation between int and other type is unsupported.

Javscript function, returns Python object.

Parameters:
Name Type Description
other Sk.builtin.object

The Python object by which to left shift

Source:
Returns:

The result of the left shift

Type
Sk.builtin.int_ | Sk.builtin.lng | Sk.builtin.NotImplemented

nb$inplace_or(othernon-null) → {Sk.builtin.int_|Sk.builtin.lng|Sk.builtin.NotImplemented}

Compute the bitwise OR of this instance and a Python object (i.e. this |= other).

Returns NotImplemented if inplace bitwise OR operation between int and other type is unsupported.

Javscript function, returns Python object.

Parameters:
Name Type Description
other Sk.builtin.object

The Python object to OR with this one

Source:
Returns:

The result of the disjunction

Type
Sk.builtin.int_ | Sk.builtin.lng | Sk.builtin.NotImplemented

nb$inplace_rshift(othernon-null) → {Sk.builtin.int_|Sk.builtin.lng|Sk.builtin.NotImplemented}

Compute the bitwise right shift of this instance by a Python object (i.e. this >>= other).

Returns NotImplemented if inplace bitwise right shift operation between int and other type is unsupported.

Javscript function, returns Python object.

Parameters:
Name Type Description
other Sk.builtin.object

The Python object by which to right shift

Source:
Returns:

The result of the right shift

Type
Sk.builtin.int_ | Sk.builtin.lng | Sk.builtin.NotImplemented

nb$inplace_xor(othernon-null) → {Sk.builtin.int_|Sk.builtin.lng|Sk.builtin.NotImplemented}

Compute the bitwise XOR of this instance and a Python object (i.e. this ^= other).

Returns NotImplemented if inplace bitwise XOR operation between int and other type is unsupported.

Javscript function, returns Python object.

Parameters:
Name Type Description
other Sk.builtin.object

The Python object to XOR with this one

Source:
Returns:

The result of the exclusive disjunction

Type
Sk.builtin.int_ | Sk.builtin.lng | Sk.builtin.NotImplemented

nb$invert() → {Sk.builtin.int_}

Compute the bitwise inverse of this instance (i.e. ~this).

Javscript function, returns Python object.

Source:
Returns:

The result of the inversion

Type
Sk.builtin.int_

nb$isnegative() → {boolean|Sk.builtin.NotImplemented}

Determine if this instance is negative.

Javscript function, returns Javascript object or Sk.builtin.NotImplemented.

Overrides:
Source:
Returns:

true if this instance is negative, false otherwise

Type
boolean | Sk.builtin.NotImplemented

nb$ispositive() → {boolean|Sk.builtin.NotImplemented}

Determine if this instance is positive.

Javscript function, returns Javascript object or Sk.builtin.NotImplemented.

Overrides:
Source:
Returns:

true if this instance is positive, false otherwise

Type
boolean | Sk.builtin.NotImplemented

nb$lshift(othernon-null) → {Sk.builtin.int_|Sk.builtin.lng|Sk.builtin.NotImplemented}

Compute the bitwise left shift of this instance by a Python object (i.e. this << other).

Returns NotImplemented if bitwise left shift operation between int and other type is unsupported.

Javscript function, returns Python object.

Parameters:
Name Type Description
other Sk.builtin.object

The Python object by which to left shift

Source:
Returns:

The result of the left shift

Type
Sk.builtin.int_ | Sk.builtin.lng | Sk.builtin.NotImplemented

nb$multiply(othernon-null) → {Sk.builtin.numtype|Sk.builtin.NotImplemented}

Multiply this instance by a Python object and return the result (i.e. this * other).

Returns NotImplemented if multiplication between this type and other type is unsupported.

Javscript function, returns Python object.

Parameters:
Name Type Description
other Sk.builtin.object

The multiplier, which must be a Python object.

Overrides:
Source:
Returns:

The result of the multiplication

Type
Sk.builtin.numtype | Sk.builtin.NotImplemented

nb$negative() → {Sk.builtin.numtype|Sk.builtin.NotImplemented}

Compute the unary negative of this instance (i.e. -this).

Javscript function, returns Python object.

Overrides:
Source:
Returns:

A copy of this instance with the value negated

Type
Sk.builtin.numtype | Sk.builtin.NotImplemented

nb$nonzero() → {boolean|Sk.builtin.NotImplemented}

Determine if this instance is nonzero.

Javscript function, returns Javascript object or Sk.builtin.NotImplemented.

Overrides:
Source:
Returns:

true if this instance is not equal to zero, false otherwise

Type
boolean | Sk.builtin.NotImplemented

nb$or(othernon-null) → {Sk.builtin.int_|Sk.builtin.lng|Sk.builtin.NotImplemented}

Compute the bitwise OR of this instance and a Python object (i.e. this | other).

Returns NotImplemented if bitwise OR operation between int and other type is unsupported.

Javscript function, returns Python object.

Parameters:
Name Type Description
other Sk.builtin.object

The Python object to OR with this one

Source:
Returns:

The result of the disjunction

Type
Sk.builtin.int_ | Sk.builtin.lng | Sk.builtin.NotImplemented

nb$positive() → {Sk.builtin.numtype|Sk.builtin.NotImplemented}

Compute the unary positive of this instance (i.e. +this).

Javscript function, returns Python object.

Overrides:
Source:
Returns:

A copy of this instance with the value unchanged

Type
Sk.builtin.numtype | Sk.builtin.NotImplemented

nb$power(othernon-null, modopt, non-null) → {Sk.builtin.numtype|Sk.builtin.NotImplemented}

Raise this instance by a Python object, optionally modulo the exponent, and return the final result.

If mod is undefined, return this ** other. Else, return (this ** other) % mod.

Returns NotImplemented if exponentiation or modulation between this type and other type is unsupported.

Javscript function, returns Python object.

Parameters:
Name Type Attributes Description
other Sk.builtin.object

The exponent, which must be a Python object.

mod Sk.builtin.object <optional>

The optional divisor, which must be a Python object if defined.

Overrides:
Source:
Returns:

The result of the exponentiation.

Type
Sk.builtin.numtype | Sk.builtin.NotImplemented

nb$reflected_add()

Source:

nb$reflected_divide()

Source:

nb$reflected_divmod()

Source:

nb$reflected_floor_divide()

Source:

nb$reflected_multiply()

Source:

nb$reflected_power()

Source:

nb$reflected_remainder()

Source:

nb$reflected_subtract()

Source:

nb$remainder(othernon-null) → {Sk.builtin.numtype|Sk.builtin.NotImplemented}

Modulo this instance by a Python object and return the result (i.e. this % other).

Returns NotImplemented if modulation between this type and other type is unsupported.

Javscript function, returns Python object.

Parameters:
Name Type Description
other Sk.builtin.object

The divisor, which must be a Python object.

Overrides:
Source:
Returns:

The result of the modulation

Type
Sk.builtin.numtype | Sk.builtin.NotImplemented

nb$rshift(othernon-null) → {Sk.builtin.int_|Sk.builtin.lng|Sk.builtin.NotImplemented}

Compute the bitwise right shift of this instance by a Python object (i.e. this >> other).

Returns NotImplemented if bitwise right shift operation between int and other type is unsupported.

Javscript function, returns Python object.

Parameters:
Name Type Description
other Sk.builtin.object

The Python object by which to right shift

Source:
Returns:

The result of the right shift

Type
Sk.builtin.int_ | Sk.builtin.lng | Sk.builtin.NotImplemented

nb$subtract(othernon-null) → {Sk.builtin.numtype|Sk.builtin.NotImplemented}

Subtract a Python object from this instance and return the result (i.e. this - other).

Returns NotImplemented if subtraction between this type and other type is unsupported.

Javscript function, returns Python object.

Parameters:
Name Type Description
other Sk.builtin.object

The Python object to subtract.

Overrides:
Source:
Returns:

The result of the subtraction.

Type
Sk.builtin.numtype | Sk.builtin.NotImplemented

nb$xor(othernon-null) → {Sk.builtin.int_|Sk.builtin.lng|Sk.builtin.NotImplemented}

Compute the bitwise XOR of this instance and a Python object (i.e. this ^ other).

Returns NotImplemented if bitwise XOR operation between int and other type is unsupported.

Javscript function, returns Python object.

Parameters:
Name Type Description
other Sk.builtin.object

The Python object to XOR with this one

Source:
Returns:

The result of the exclusive disjunction

Type
Sk.builtin.int_ | Sk.builtin.lng | Sk.builtin.NotImplemented

numberCompare() → {number|Sk.builtin.NotImplemented}

Compare this instance's value to another Python object's value.

Returns NotImplemented if comparison between int and other type is unsupported.

Javscript function, returns Javascript object or Sk.builtin.NotImplemented.

Source:
Returns:

negative if this < other, zero if this == other, positive if this > other

Type
number | Sk.builtin.NotImplemented

ob$eq(other) → {Sk.builtin.bool|Sk.builtin.NotImplemented}

Perform equality check between this instance and a Python object (i.e. this == other).

Implements __eq__ dunder method.

Javascript function, returns Python object.

Parameters:
Name Type Description
other Object

The Python object to check for equality.

Overrides:
Source:
Returns:

true if equal, false otherwise

Type
Sk.builtin.bool | Sk.builtin.NotImplemented

ob$ge(other) → {Sk.builtin.bool|Sk.builtin.NotImplemented}

Determine if this instance is greater than or equal to a Python object (i.e. this >= other).

Implements __ge__ dunder method.

Javascript function, returns Python object.

Parameters:
Name Type Description
other Object

The Python object to compare.

Overrides:
Source:
Returns:

true if this >= other, false otherwise

Type
Sk.builtin.bool | Sk.builtin.NotImplemented

ob$gt(other) → {Sk.builtin.bool|Sk.builtin.NotImplemented}

Determine if this instance is greater than a Python object (i.e. this > other).

Implements __gt__ dunder method.

Javascript function, returns Python object.

Parameters:
Name Type Description
other Object

The Python object to compare.

Overrides:
Source:
Returns:

true if this > other, false otherwise

Type
Sk.builtin.bool | Sk.builtin.NotImplemented

ob$le(other) → {Sk.builtin.bool|Sk.builtin.NotImplemented}

Determine if this instance is less than or equal to a Python object (i.e. this <= other).

Implements __le__ dunder method.

Javascript function, returns Python object.

Parameters:
Name Type Description
other Object

The Python object to compare.

Overrides:
Source:
Returns:

true if this <= other, false otherwise

Type
Sk.builtin.bool | Sk.builtin.NotImplemented

ob$lt(other) → {Sk.builtin.bool|Sk.builtin.NotImplemented}

Determine if this instance is less than a Python object (i.e. this < other).

Implements __lt__ dunder method.

Javascript function, returns Python object.

Parameters:
Name Type Description
other Object

The Python object to compare.

Overrides:
Source:
Returns:

true if this < other, false otherwise

Type
Sk.builtin.bool | Sk.builtin.NotImplemented

ob$ne(other) → {Sk.builtin.bool|Sk.builtin.NotImplemented}

Perform non-equality check between this instance and a Python object (i.e. this != other).

Implements __ne__ dunder method.

Javascript function, returns Python object.

Parameters:
Name Type Description
other Object

The Python object to check for non-equality.

Overrides:
Source:
Returns:

true if not equal, false otherwise

Type
Sk.builtin.bool | Sk.builtin.NotImplemented

round$(self, ndigits) → {Sk.builtin.int_}

Round this instance to a given number of digits, or zero if omitted.

Implements __round__ dunder method.

Javascript function, returns Python object.

Parameters:
Name Type Description
self Sk.builtin.int_

This instance.

ndigits Object | number

The number of digits after the decimal point to which to round.

Source:
Returns:

The rounded integer.

Type
Sk.builtin.int_

str$(base, sign) → {string}

Convert this instance's value to a Javascript string.

Javascript function, returns Javascript object.

Parameters:
Name Type Description
base number

The base of the value.

sign boolean

true if the value should be signed, false otherwise.

Source:
Returns:

The Javascript string representation of this instance.

Type
string

tp$hash() → {Sk.builtin.int_}

Return the hash value of this instance.

Javascript function, returns Python object.

Overrides:
Source:
Returns:

The hash value

Type
Sk.builtin.int_

tp$index() → {number}

Return this instance's Javascript value.

Javascript function, returns Javascript object.

Source:
Returns:

This instance's value.

Type
number

tp$str() → {Sk.builtin.str}

Return the string representation of this instance.

Javascript function, returns Python object.

Source:
Returns:

The Python string representation of this instance.

Type
Sk.builtin.str