python-dev Summary for 2003-05-16 through 2003-05-31

This is a summary of traffic on the python-dev mailing list from May 16, 2003 through May 31, 2003. It is intended to inform the wider Python community of on-going developments on the list and to have an archived summary of each thread started on the list. To comment on anything mentioned here, just post to or comp.lang.python with a subject line mentioning what you are discussing. All python-dev members are interested in seeing ideas discussed by the community, so don't hesitate to take a stance on something. And if all of this really interests you then get involved and join python-dev!

This is the eighteenth summary written by Brett Cannon (has his own room with a door for the first time in over 22 years).

All summaries are archived at .

Please note that this summary is written using reStructuredText which can be found at . Any unfamiliar punctuation is probably markup for reST (otherwise it is probably regular expression syntax or a typo =); you can safely ignore it, although I suggest learning reST; its simple and is accepted for PEP markup. Also, because of the wonders of programs that like to reformat text, I cannot guarantee you will be able to run the text version of this summary through Docutils as-is unless it is from the original text file.

The in-development version of the documentation for Python can be found at and should be used when wanting to look up any documentation on something mentioned here. To view files in the Python CVS online, go to .

Summary Announcements

Sorry about the delay for this summary. I was visiting my mother and that puts me out of my hacking groove. I also had a roommate move out which means I got to move into his room. And on top of all of that I just decided where I am going to go for grad school in computer science ( Cal Poly San Luis Obispo ). Life just likes to dump everything on you at once, huh?

C new-style classes and GC

Jim Fulton updated the tutorial for creating new C types to use new-style classes. This led to the question of what the right way was for dealing with garbage collection. In terms of the tp_dealloc slot, having it call obj->ob_type->tp_free is best since that works the best when the type is subclassed.

This also led to a discussion about the magic of PyType_Ready and whether it should do more. This wonderful function fills in tp_alloc and tp_free if tp_base and tp_bases are empty (they are set appropriately for PyBaseObject which is the C version of object). What was changed was that now the function does the right thing if the object should be checked for cycles based on settings in tp_flags.

Paul Moore was worried about the loss of the tutorial for classic types. The response was that as long as they don't mess with there code it will continue to work, but if they decide to change something they should probably update. Michael Hudson's Misc/pymemcompat.h file is also helpful since it allows you to use 2.3's memory API but macro-replaces the call with the proper code all the way back to 1.5.2 . It was suggested adding a Misc/pyapipcompat.h for PyAPI_FUNC, PyAPI_DATA, and PyMODINIT_FUNC.

Attribute lookup

For the last summary I asked for the help of python-dev to find out the exact algorithm used to do attribute lookup for new-style classes (I don't care about classic classes since they are sooo 2.1 =). A bunch of people jumped in and made suggestions, but I am going to steal the explanation from Raymond Hettinger's explanation of descriptors which can be found at . =)

The attribute lookup order gives "data descriptors priority over instance variables, instance variables priority over non-data descriptors, and assigns lowest priority to __getattr__ if provided." This is all is done by object.__getattribute__ . If you define your own __getattribute__ none of this is done unless you explicitly call object's implementation. You have to worry about calling a descriptor's __get__ method yourself if you decide not to call object.__getattribute__ .

Raymond's descriptor essay/explanation/(group of words put together in attempt to make a coherent idea which he does) explains the difference between a data descriptor and non-data descriptor, but instead of make you wait I will just tell you. A data descriptor defines both a __get__ and __set__ method while a non-data descriptor defines only __get__. This makes sense when you think about non-data-descriptors such as functions. You have no need to assign to a function so not having a __set__ in no way harms the usage of a function plus it negates the need for any special flag or anything to define the difference between data and non-data descriptors.


Splinter threads:

What started off as Jeffrey Robert's introducing himself ended up becoming a short howto on how to get involved on python-dev. It was suggested to work on pyPy (although that is not exactly python-dev but is still cool and you could learn a lot about Python on a more abstract level =). Multiple people suggested working on bugs and patches. I specifically suggested looking at patches in development to learn what they were doing to the code's semantics. Mention of the AST branch and working on that was also brought up.

Terrence Way then introduced himself and mentioned he had written a PEP about programming with contracts. It led to, in the end, Guido saying that he wanted to wait and let more implementations get out there and be weeded out before he started pronouncing on PEPs on the subject.


test_urllibnet failing on Windows
os.fdopen does not work with sockets under Windows when fetching its argument from fileno .
[development doc updates]
Here is a simple intelligence test: what do you think this email was about based on its subject? Get it right and you earned yourself a lollipop (on your own dime).
test_time fails with current CVS
A bug report has been filed.
a strange case
Splinter threads:
Unifying modules and classes?

Apparently the 2.2.x branch allows you to subclass a module. This has been fixed in 2.3 . And once again Guido stated that erasing the line separating classes and modules is not going to happen while his benevolently dictating body still has air in it (okay, he didn't say it that way, but I am sure he wouldn't object to a little artistic license to get his point across =). But if you really feel the need to have a module be a class just stick an instance in sys.modules; just don't expect everything to play well with it, though.

test_bsddb185 failing under OS X
Tests were failing for me under OS X. After Skip Montanaro and I independently came up with a better way for the test to clean up after itself the tests passed from some odd reason.
Need advice, maybe support
Christian Tismer was given two bits in tp_flags for Stackless to create Stackless-aware types that can identify recursive, indirect function calls in C. The two bits will greatly simplify the implementation of Stackless 3.0.
[Python-Dev] SF oddity
Remember folks, look out for horizontal scroll bars along with vertical ones.
Weekly Python Bug/Patch Summary
doctest extensions
Jim Fulton came up with some possible additions for doctest. You can see them at . If you would like to see them added then speak up.
+= on return of function call result
This is a continuation from last summary. Samuele Pedroni wrote a simple function that simulates what was originally desired.
Using emacs' unexec to speed Python startup
Splinter threads:

Some people tried to speed up loading Python for some editor when what they should have been doing is learning how to use a better editor. =)

[debian build error]
Some issue with using Debian packages and Python 2.2 with gcc 3.3 and libstdc++5. A Debian bug report has been filed.
urllib2 proxy support broken?
Yes, but Gustavo Niemeyer found the bug and came up with a patch.
Python Run-Time System and Extensions
Daniel Silva is writing a compiler for Python to PLT Scheme code. He asked for suggestions on which of two ways to go for being able to run C extension code.
Descriptor API
We all learned what the difference is between a data and non_data descriptor (which you can know too by reading the summary for Attribute lookup ).
Of what use is commands.getstatus()
Guido ended up saying the commmands module should be redesigned, probably put into shutil, and then have the old version deprecated.
Change to ossaudiodev setparameters() method
Some day Greg Ward will get his ossaudiodev module to work on both Guido's home machine and work machine.
RE: Decimal class
A Decimal class is currently being worked on in the CVS sandbox. The question as to whether the values should be immutable was raised. Everyone agreed that they should be immutable.
install debian package
python-dev is not the right place to bring up issues with Debian packages.
Release question
Branches in CVS for Python are pretty much only used for minor versions (the "3" in "2.3.x"). Since 2.3 is in beta that means no semantic changes to the code. Any new features must wait for 2.4 development to start which occurs when 2.3 is out the door.
Algoritmic Complexity Attack on Python
Someone tried to point out that Python was vulnerable to an attack if you naively took in user-supplied keys to a dictionary. The big lesson is that Python's hash function can change between releases and that it will always be as fast as possible but can still be nailed by worst-case situations.
KeyboardInterrupt on Windows
An optimization on the JUMP_ABSOLUTE opcode was not dealing with asynchronous exceptions since it was skipping the signal checks in the interpreter loop. It has been fixed.
more-precise instructions for "Python.h first"?
David Abrahams didn't like the restriction of having to put Python.h before all other headers in C/C++ code. The problem is some key macro definitions are set in Python.h that are needed on some platforms.