PyCon DC 2004
Python's creator said, "What will the future bring for Python? Darned if I know. Maybe somebody in the future can bring back the keys to my time machine." In the meantime Guido declared Python 2.2 an ex-release, said 2.3.3 is current and 2.4 will be "better, faster, and bigger". It will be faster thanks to new library modules and more C code. The latest summary of completed and planned changes is in PEP 320: Python 2.4 Release Schedule, and a gentler introduction is in "What's New in Python 2.4" (URLs below). The full details of completed changes are in the file Misc/NEWS in the Python source, and Misc/HISTORY details all the past changes since Python 0.9.0.
Guido said the current dilemmas for 2.4 are deciding on a function decorator syntax, getting people used to generator expressions and speeding up function calls by shrinking the stack frames.
A decorator is a function that takes another function as an argument and returns a modified version of that function. Python's classmethod and staticmethod builtins are decorators. Python needs a generic syntax to apply decorators in the def line, remembering that a function can have multiple decorators. Five syntaxes are under consideration:
def foo [classmethod] (cls, arg1, arg2): # Guido's favorite, and preferred by PyCon hand vote. # Disadvantage: args separated from function name. [classmethod] def foo(cls, arg1, arg2) # Disadvantage: 'def' not at left column. def [classmethod] foo(cls, arg1, arg2): # Disadvantage: function name not near left column. def foo(cls, arg1, arg2) [classmethod]: # Disadvantage: decorator hidden behind long argument list. def foo(cls, arg1, arg2): [classmethod] # Disadvantage: decorator not on 'def' line.
Generator expressions are like list interpolations, but they create an iterator rather than a list. That's good because usually you're going to iterate over it once anyway, so a list would waste memory. The syntax is quite unobtrusive; simply put the keywords in a normal parenthesized expression:
sum(x * 2 for x in range(10))
If there's a comma on either side, an extra pair of parentheses is required. This eliminates ambiguity in argument lists.
The long-awaited Python 3.0 has been put off again, this time until his son Orlijn goes to college (he's now 1 1/2) or until Guido retires or goes on a sabbatical. His top wishlist items for 3.0 are:
convert functions returning lists into generators wherever feasible. ("Iterators are the force of the future.") Users will have to type list(range(10)) if they really need a list.
make the module hierarchy in the standard library deeper.
learn from IronPython, Starkiller and PyPy.
IronPython is a rewrite of Python in C# for Microsoft's Common Language Runtime. Every port of Python to a different virtual machine tests the robustness of the language and standard libraries and often reveals some efficiency tricks that can be ported back to CPython. Starkiller is discussed below; it's a statically typed C++ compiler for Python programs. PyPy is a rewrite of Python in Python. (Yes, some people actually do this.) Q&A on a variety of topics is in the SubEthaEdit notes.
Homage should be paid to last year's most controversial topic, if-then-else expressions (PEP 308). Guido did not see it as important because the if statement exists, but he was willing to add it if the community overwhelmingly favored it and agreed on a syntax. The community could do neither, so Guido rejected it forevermore.
Bruce Eckel gave a humorous talk about static vs. dynamic typing. You can read more about it in the SubEthaEdit notes and in Bruce's Web log (see Resources). He quoted Andrew Dalke's comment about typing: "If you only care if it quacks, you don't need to check that it's a duck." Bruce maintains that even with static typing you still have to do checks at runtime for things the compiler can't catch, so why obscure the code with types and casts? He thinks one's time would be better spent writing a robust automated test suite (unittest) than on debugging type casts.
To me, the three most interesting talks were those discussing Nevow, Quixote and Atop. Nevow is the successor to Twisted Woven, a high-level Web application framework. Because I've worked with Webware and Cheetah extensively, I was curious about the differences. Nevow, like most other non-PSP/PHP servers, is based on servlets. Something parses the URL and invokes a servlet instance somewhere, and a servlet method returns or writes the HTML output. In Webware, that something that parses the URL is Webware itself. In Nevow, as in twisted.web that I described last year, your application class registers itself as the manager of a certain URL part (=directory), and then your
.locateChild(self, request, parts)
method has to handle or delegate everything to the right of that part.
Nevow's most intriguing aspect is its built-in model-view-controller (MVC) framework, which strictly separates generic logic calculations (the data) from the specific view desired (the rendering). A servlet (a Page subclass) associates itself with an HTML template. The template might contain placeholder tags like this:
<span nevow:data="currentMonth" nevow:render="month"> <h1><nevow:slot name="label">Bogus label</nevow:slot></h1> ... </span>
(Here and throughout I've used modified examples from the presentations.) Nevow sees "currentMonth" and calls a method .data_currentMonth in your servlet. That method returns some values needed in the <span>, possibly based on GET parameters or other criteria. Nevow then sees "month" and calls .render_month(self, context, data). That method receives the data returned by the previous method and fills the slot with its actual value:
This replaces the entire slot tag. Cheetah fans note that the template is not pulling values from a dictionary; rather, the method is pushing values into the template. The rendering method also can extract another type of tag, the pattern, which it can use in a for loop to generate repetitive sections, for example, table rows.
|Designing Electronics with Linux||May 22, 2013|
|Dynamic DNS—an Object Lesson in Problem Solving||May 21, 2013|
|Using Salt Stack and Vagrant for Drupal Development||May 20, 2013|
|Making Linux and Android Get Along (It's Not as Hard as It Sounds)||May 16, 2013|
|Drupal Is a Framework: Why Everyone Needs to Understand This||May 15, 2013|
|Home, My Backup Data Center||May 13, 2013|
- New Products
- Linux Systems Administrator
- Senior Perl Developer
- Technical Support Rep
- UX Designer
- Designing Electronics with Linux
- Dynamic DNS—an Object Lesson in Problem Solving
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- Using Salt Stack and Vagrant for Drupal Development
- Nice article, thanks for the
10 hours 26 min ago
- I once had a better way I
16 hours 12 min ago
- Not only you I too assumed
16 hours 30 min ago
- another very interesting
18 hours 23 min ago
- Reply to comment | Linux Journal
20 hours 16 min ago
- Reply to comment | Linux Journal
1 day 3 hours ago
- Reply to comment | Linux Journal
1 day 3 hours ago
- Favorite (and easily brute-forced) pw's
1 day 5 hours ago
- Have you tried Boxen? It's a
1 day 11 hours ago
- seo services in india
1 day 15 hours ago
Enter to Win an Adafruit Pi Cobbler Breakout Kit for Raspberry Pi
It's Raspberry Pi month at Linux Journal. Each week in May, Adafruit will be giving away a Pi-related prize to a lucky, randomly drawn LJ reader. Winners will be announced weekly.
Fill out the fields below to enter to win this week's prize-- a Pi Cobbler Breakout Kit for Raspberry Pi.
Congratulations to our winners so far:
- 5-8-13, Pi Starter Pack: Jack Davis
- 5-15-13, Pi Model B 512MB RAM: Patrick Dunn
- 5-21-13, Prototyping Pi Plate Kit: Philip Kirby
- Next winner announced on 5-27-13!
Free Webinar: Hadoop
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Some of key questions to be discussed are:
- What is the “typical” Hadoop cluster and what should be installed on the different machine types?
- Why should you consider the typical workload patterns when making your hardware decisions?
- Are all microservers created equal for Hadoop deployments?
- How do I plan for expansion if I require more compute, memory, storage or networking?