What’s New In Python 3.1

Author:No one so far
Release:3.1a1
Date:March 07, 2009

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 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.)

Table Of Contents

Previous topic

What’s New in Python

Next topic

What’s New In Python 3.0

This Page