Saturday, February 25, 2006

PyCon notes part 2: Guido's keynote

Some notes I took during Guido's "State of the Python Universe" keynote:

Guido started by praising a few community activities:
  • converting the source code management system for Python from cvs to subversion, hosted away from SourceForge at svn.python.org
    • they got tired of waiting for SourceForge to sync the read-only cvs repositories with the live repository
  • deploying buildbot for continuous integration of the build-and-test process of Python on many different platforms (I was particularly pleased by this remark, since it validates some of the points Titus and I emphasized during our tutorial; Guido went as far as saying "I hope all of you will start deploying buildbot for your own projects")
  • deploying and hosting Python packages at the CheeseShop, and using tools such as easy_install to download and install them (here Guido gave the example of TurboGears, which depends on many different packages, yet is not very hard to install via setuptools)
  • converting the python.org Web site to a more modern look and feel -- the new site is still in beta, but is supposed to go live next Sunday March 5th
The bulk of Guido's talk consisted in the presentation of new features in Python 2.5. Here are some of the things I wrote down:

The release candidate and the final version for 2.5 are slated for Sept. 2006, but might happen a bit earlier if Anthony Baxter, the release manager, has his way.

New in Python 2.5
  • absolute/relative imports (PEP 328) -- hurray!
    • you will be able to write:
  • from . import foo # current package
  • from .. import foo # parent package
  • from .bar import foo # bar sub-package
  • from ..bar import foo # bar sibling
    • any number of leading dots will be allowed
  • conditional expressions (PEP 308)
    • Guido's syntax choice: EXPR1 if COND else EXPR2
  • try/except/finally reunited (PEP 341)
    • you will be able to write:
    • try:
      • BLOCK1
    • except:
      • BLOCK2
    • finally:
      • BLOCK3
  • generator enhancements (PEP 342, PJE)
    • yield will be an expression, as well as a statement
    • send method will basically make it possible to have coroutines
    • can also send exceptions
  • with statement (PEP 343, Mike Bland)
    • with EXPR [as VAR]:
      • BLOCK
    • useful for mutexes, database commit/rollback
    • context manager object will be returned by EXPR.__context__ and will have __enter__ and __exit__ methods
    • some standard objects will have context managers:
      • mutexes
      • Decimal
      • files
        • you will be able to write:
        • with open(filename) as f:
          • # read data from f (NOTE: f will be close at block end)
  • exceptions revisited (PEP 325, Brett Cannon)
    • make standard Exception class a new style class
    • have new class BaseException as root of Exception hierarchy
    • all exceptions except KeyboardInterrupt and SystemExit are supposed to continue to inherit from Exception, not from BaseException directly
  • AST-based compiler (Jeremy Hylton)
    • new bytecode compiler using ABSTRACT syntax trees instead of CONCRETE
    • new compiler is easier to modify
    • Python code will be able to get access to the AST as well
  • ssize_t (PEP 353 Martin v. Loewis)
    • use C type ssize_t instead of int for all indexing (and things such as length of strings)
    • needed for 64-bit platforms
    • allows indexing of strings with > 2GB characters (and lists, although a list with > 2GB elements is not likely to fit in today's standard RAM amounts, but Guido said we'll be ready for the future)
  • python -m . (Nick Coghlan)
    • will run given module in given package as __main__
    • it was already possible to run python -m in Python 2.4
    • expansion to submodules of packages was tricky (PEP 302)
    • solution proved to be the runpy.py module
    • use case: python -m test.regrtest
New in the Python 2.5 standard library
  • hashlib (supports SHA-224 to -512)
  • cProfile (Armin Rigo)
  • cElementTree (Fredrik Lundh)
  • Hopefully also
    • ctypes
    • wsgiref
    • setuptools
    • bdist_msi, bdist_egg options for distutils
Other miscellaneous stuff:
  • collections.defaultdict (for multimaps) will enable you to write code such as:
    • from collections import defaultdict
    • mm = defaultdict(list) # IMPORTANT: list is a factory, not a value
    • def add(key, *values):
      • mm[key] += values
And finally....lambda lives! (thunderous applause)

The Q&A session wasn't that great, mainly due to some less-than-fortunate questions about design choices that Guido did his best to answer without insulting anybody. He got asked at the very end if he likes working at Google and he said something like "Talk to me after the talk. I LOVE it there!"

1 comment:

Anonymous said...

It seems great, but a bit is still unclear.
Does PEP343 means that now for the case

with 5 as b:
    a = b
print a
print b


"print a" will output 5, but "print b" will decide that "b" variable is not defined? The absence of variable visibility encapsulation within the area of variable usage really stopped me from Python and turned me to Ruby, even though Ruby seems less powerful.

Modifying EC2 security groups via AWS Lambda functions

One task that comes up again and again is adding, removing or updating source CIDR blocks in various security groups in an EC2 infrastructur...