Brief highlight of Python 2.5

Highlights of Python 2.5:

New Language Features

  • Internally, the Python compiler now converts the source code to an
    abstract syntax tree (AST) before producing the bytecode.
  • The ‘with’ operator replaces a common try/finally idiom that results in much
    cleaner and safer code.
  • Generators gained push, throw and close methods. Values passed to push
    will be returned by the yield statement when the generator is resumed.
    throw takes an exception and causes the yield statement to raise the
    passed exception in the generator. close is used to terminate a generator.
    This turns generators into a form of coroutine and makes them even more
    powerful.
  • Conditional expressions of the form (format: TrueValue if Condition else FalseValue)
    were added.
  • Import can use both relative and absolute imports when inside packages.
  • Try/except/finally were changed so that it’s now possible to have both except
    blocks and a finally block for the same try block.
  • Exceptions have become new-style classes, and the exception hierarchy has
    been rearranged a bit.
  • Internally, Python was changed to use the Py_ssize_t type – this means that
    many structures that were limited to 2^32 objects can now hold up to 2^64
    instead.

New or Upgraged builtins:

  • partition and rpartition methods were added to str and unicode. This
    greatly simplifies the process of searching and splitting strings.
  • New builtins any and all evaluate whether an iterator contains any or all
    True values, respectively.
  • min and max gained a key keyword parameter, analogous to sort.

New or Upgraded modules and packages:

  • In keeping with the theme of adding tried and true packages to the standard
    library, in 2.5 we’ve added ctypes, ElementTree, hashlib, sqlite3 and wsgiref
    to the standard library that ships with Python.
  • Google’s summer of code resulted in a new cProfile profiling module. This is a
    much more efficient version of the venerable profile.py module that’s shipped
    with Python for many many years. GSoC also gave us a rewritten mailbox module
    that can both read and write mailboxes in a variety of formats.
  • The struct module was updated to support a new Struct object. These are similar
    to the re module’s compiled form of regular expressions.
  • Some other smaller modules added to the standard library include uuid, msilib
    and spwd.

Check out AMK’s section on Whats New in Python 2.5 for detailed treatment. I will put my comments on the changes in new version in detail, in comming days.

Looking forward to get my hands wet on it.

powered by performancing firefox


About this entry