summaryrefslogtreecommitdiffstats
path: root/Doc/whatsnew/3.1.rst
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2008-12-17 16:19:07 (GMT)
committerMark Dickinson <dickinsm@gmail.com>2008-12-17 16:19:07 (GMT)
commit54bc1ec4c7689ceab900f453fdd4c8cf5a308e59 (patch)
tree87dd2371d042f3b8e63a32a4bda589ccce0b2303 /Doc/whatsnew/3.1.rst
parent81c93fb45c4076506a5ab3d89aeec1f42e0e6be2 (diff)
downloadcpython-54bc1ec4c7689ceab900f453fdd4c8cf5a308e59.zip
cpython-54bc1ec4c7689ceab900f453fdd4c8cf5a308e59.tar.gz
cpython-54bc1ec4c7689ceab900f453fdd4c8cf5a308e59.tar.bz2
Forward merge of r67822 to py3k: add bit_length method to int.
Diffstat (limited to 'Doc/whatsnew/3.1.rst')
-rw-r--r--Doc/whatsnew/3.1.rst22
1 files changed, 22 insertions, 0 deletions
diff --git a/Doc/whatsnew/3.1.rst b/Doc/whatsnew/3.1.rst
index a244568..7df4d1e 100644
--- a/Doc/whatsnew/3.1.rst
+++ b/Doc/whatsnew/3.1.rst
@@ -66,4 +66,26 @@ This article explains the new features in Python 3.1, compared to 3.0.
.. ======================================================================
+Other Language Changes
+======================
+
+Some smaller changes made to the core Python language are:
+
+* The :func:`int` type gained a ``bit_length`` method that returns the
+ number of bits necessary to represent its argument in binary::
+
+ >>> n = 37
+ >>> bin(37)
+ '0b100101'
+ >>> n.bit_length()
+ 6
+ >>> n = 2**123-1
+ >>> n.bit_length()
+ 123
+ >>> (n+1).bit_length()
+ 124
+
+ (Contributed by Fredrik Johansson and Victor Stinner; :issue:`3439`.)
+
+
.. ======================================================================