summaryrefslogtreecommitdiffstats
path: root/Python/Dependencies/future-0.18.2/docs/int_object.rst
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2022-12-17 17:26:16 -0800
committeryum <yum.food.vr@gmail.com>2022-12-17 17:26:16 -0800
commit4d836989720523cd0363927e3e066f56b9dc445c (patch)
treef7a9ff7cb50eda1ff29e91c78067dcc5e0ce6233 /Python/Dependencies/future-0.18.2/docs/int_object.rst
parentda754e9cf5b192239826aa1619e1ada3c98daa45 (diff)
Check in `future` package
I hit some issues installing Whisper and had to embed this package. I haven't taken the time to deeply understand what's going on. I think that embedded Python follows different rules about resolving module paths than regular system Python. Basically, `future`'s setup.py has a line like `import src`, where `src` is a module inside future (like `future/src/__init__.py`). This doesn't work unless we put that directory on the search path.
Diffstat (limited to 'Python/Dependencies/future-0.18.2/docs/int_object.rst')
-rw-r--r--Python/Dependencies/future-0.18.2/docs/int_object.rst68
1 files changed, 68 insertions, 0 deletions
diff --git a/Python/Dependencies/future-0.18.2/docs/int_object.rst b/Python/Dependencies/future-0.18.2/docs/int_object.rst
new file mode 100644
index 0000000..f774784
--- /dev/null
+++ b/Python/Dependencies/future-0.18.2/docs/int_object.rst
@@ -0,0 +1,68 @@
+.. _int-object:
+
+int
+---
+
+Python 3's ``int`` type is very similar to Python 2's ``long``, except
+for the representation (which omits the ``L`` suffix in Python 2). Python
+2's usual (short) integers have been removed from Python 3, as has the
+``long`` builtin name.
+
+Python 3::
+
+ >>> 2**64
+ 18446744073709551616
+
+Python 2::
+
+ >>> 2**64
+ 18446744073709551616L
+
+``future`` includes a backport of Python 3's ``int`` that
+is a subclass of Python 2's ``long`` with the same representation
+behaviour as Python 3's ``int``. To ensure an integer is long compatibly with
+both Py3 and Py2, cast it like this::
+
+ >>> from builtins import int
+ >>> must_be_a_long_integer = int(1234)
+
+The backported ``int`` object helps with writing doctests and simplifies code
+that deals with ``long`` and ``int`` as special cases on Py2. An example is the
+following code from ``xlwt-future`` (called by the ``xlwt.antlr.BitSet`` class)
+for writing out Excel ``.xls`` spreadsheets. With ``future``, the code is::
+
+ from builtins import int
+
+ def longify(data):
+ """
+ Turns data (an int or long, or a list of ints or longs) into a
+ list of longs.
+ """
+ if not data:
+ return [int(0)]
+ if not isinstance(data, list):
+ return [int(data)]
+ return list(map(int, data))
+
+
+Without ``future`` (or with ``future`` < 0.7), this might be::
+
+ def longify(data):
+ """
+ Turns data (an int or long, or a list of ints or longs) into a
+ list of longs.
+ """
+ if not data:
+ if PY3:
+ return [0]
+ else:
+ return [long(0)]
+ if not isinstance(data,list):
+ if PY3:
+ return [int(data)]
+ else:
+ return [long(data)]
+ if PY3:
+ return list(map(int, data)) # same as returning data, but with up-front typechecking
+ else:
+ return list(map(long, data))