Skip to content

Commit 96ce020

Browse files
committed
Update text in rationale describing conversions of primitive types
1 parent b70b987 commit 96ce020

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

peps/pep-0818.rst

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,14 @@ JavaScript has the following immutable types: ``string``, ``undefined``,
110110
``boolean``, ``number`` and ``bigint``. It also has the special value ``null``.
111111

112112
Of these, ``string`` and ``boolean`` directly correspond to ``str`` and
113-
``bool``. ``number`` and ``bigint`` awkwardly correspond to ``float`` and
114-
``int``. ``undefined`` is the default value for a missing argument so it
113+
``bool``. We convert a ``number`` to an ``int`` if ``Number.isSafeInteger()``
114+
returns ``true`` and otherwise we convert it to a ``float``. Conversely we
115+
convert ``float`` to ``number`` and we convert ``int`` to ``number`` unless it
116+
exceeds ``2**53`` in which case we convert it to a ``bigint``. We make a new
117+
subclass of ``int`` called ``JsBigInt`` to act as the conversion for
118+
``bigint``.``undefined`` is the default value for a missing argument so it
115119
corresponds to ``None``. We invent a new falsey singleton Python value
116-
``jsnull`` to act as the conversion of ``null``. We also make a new type
117-
``JsBigInt`` to act as the conversion for ``bigint``. All other types are
118-
proxied.
120+
``jsnull`` to act as the conversion of ``null``. All other types are proxied.
119121

120122
In particular, even though ``tuples`` are immutable, they have no equivalent in
121123
JavaScript so we proxy them. They can be manually converted to an ``Array`` with

0 commit comments

Comments
 (0)