I'm interested in seeing a good way to write tail calls in Python. Some
algorithms are more readable when expressed using tail recursion.
I know tail call optimization has been discussed before , but I would
like to consider a different approach. The previous discussion centered
on implicit tail call optimization, which incurs the risk of changing
the behavior of currently working code. (For example, is it safe to
optimize tail calls within try...finally blocks? Probably not. And I
generally want all stack frames to appear in tracebacks, unless I say
I would like to suggest an explicit form of tail calls. A new built-in
exception type called "Return" will be added, and it will be used like this:
def fact2(n, v):
raise Return(fact2, n-1, v*n)
The interpreter will catch Return exceptions and use them to call
something else. The caller of a function that uses "raise Return" will
see the result of the tail call as the returned value, rather than the
Return exception. I am not yet considering implementation details.
Not all algorithms are good candidates for this. I used the fact2
example only because it's readily available. I know there are other
people interested in tail call optimization in Python  ; perhaps
some of them are watching and can provide better examples.
Furthermore, there might be some explicit syntax that converts "return
f(...)" statements to "raise Return(f, ...)", such as a decorator.
However, I'm less interested in the syntax and more interested in the
I would like to get some advice on which license to include/refer to in
my setup.py (and probably the source files).
This is for an extension module that is clearly (for the knowledgeable)
derived from Python's Objects/dictobject.c and Include/dictobject.h.
I first of all don't want to infringe any original license on that code.
I second would like to make sure the license for code is not a problem
to make it into Linux distributions like Ubuntu/Debian (assuming of
course the code is acceptable and fills enough of a gap that these
distros want to pick it up in the first place).
And thirdly, I although I would like my name to be associated on further
derivations of this module, that is not a strict requirement.
Should I refer to MIT, LGPL or BSD. Any particular copy of a license I
should put up on my website and refer to with a URL?
Any examples or references with a brief explanation would be much
I know I could look at what other modules use, but at this point I
rather spent time on finishing implementing the "insert" method (and
some tests) and getting my first release out (and hopefullysome
feedback), than comparing other modules for the license they chose and
try to deduct what I should use/specify for a license.
Thanks in advance
For the curious: the module is called ordereddict. It is an
implemenation in C of a dictionary with ordered keys based on Key
Insertion Order. Value updating of existing Key/Value pairs does not
reorder the keys, although I probably implement that as an
(instantiation) option after the initial version.
orderdict() does all that dict() does, except for instantiation it will
only take another ordereddict() (not a dict) or an ordered list of
pairs. Some extras (reverse(), index()) are already implemented and work
like Larosa/Foord's odict.OrderedDict() (theirs is also the example I
took for the representation of the ordereddict).
ordereddict() is 5-10% slower than dict() (especially key deletion is
'expensive') and it is 5-9 times faster than odict.OrderedDict()
I have done all of the development under Linux but will be proably be
able to test things under Windows and may, at some point even dig up my
old G4 to see how things go on OS X. I am fairly confident that the C
code is still portable, or close to it.
I apologize in advance for the somewhat provocative subject. Is the sched
module still appropriate in an increasingly event-driven world? If so, can
someone suggest how it might be used with a non-blocking delay function such
as gobject.timeout_add? It would be nice to either remark in the
documentation that the sched module doesn't play nice with event-driven
architectures or provide an example of how it can. It doesn't seem to be
possible without resorting to threads (not generally a big problem, but not
always the best choice either, depending on the environment in which you
find yourself). The delayfunc is called and when it finishes, the action
function is called.
Thanks for the quick responses. Embarrassingly, this problem turned out to
be a typo on my part. I visually double-and-triple-checked my code before
posting to this list, but I still didn't notice the typo. Sorry to send
everyone on a wild goose chase.
I've found what might be a bug in Python's % string formatting operator.
Consider the following code:
"%%(%s)=%%s" % "hello"
On "Python 2.5.1 (r251:54863, May 18 2007, 16:56:43) [GCC 3.4.4 (cygming
special, gdc 0.12, using dmd 0.125)] on cygwin" this produces the string
"%(hello)s=%s" which is what I'd expect.
On "Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit
(Intel)] on win32" this produces the following exception:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: not enough arguments for format string
Note that this is the exact same revision running on the same machine, but
it doesn't work for the win32 version and does work for the cygwin version.
I wish I had time to track down the source of the problem and submit a
patch. But unfortunately I need to get back to work, and I won't even have
the free time after work to tackle this. So I figured I'd kick it off to
the Python Dev list in case anyone deems this important enough to be worth
By the way, Python is my favorite language and I use it whenever possible
and have even gotten some co-workers to start using it. Thanks for the
I've been doing some tests on removing the GIL, and it's becoming clear that
some basic changes to the garbage collector may be needed in order for this
to happen efficiently. Reference counting as it stands today is not very
I've been looking into a few options, and I'm leaning towards the
implementing IBMs recycler GC
) since it is very similar to what is in place now from the users'
perspective. However, I haven't been around the list long enough to really
understand the feeling in the community on GC in the future of the
interpreter. It seems that a full GC might have a lot of benefits in terms
of performance and scalability, and I think that the current gc module is of
the mark-and-sweep variety. Is the trend going to be to move away from
reference counting and towards the mark-and-sweep implementation that
currently exists, or is reference counting a firmly ingrained tradition?
On a more immediately relevant note, I'm not certain I understand the full
extent of the gc module. From what I've read, it sounds like it's fairly
close to a fully functional GC, yet it seems to exist only as a
cycle-detecting backup to the reference counting mechanism. Would somebody
care to give me a brief overview on how the current gc module interacts with
the interpreter, or point me to a place where that is done? Why isn't the
mark-and-sweep mechanism used for all memory management?
Thanks a lot!
> On Oct 5, 10:31 am, Dick Moores <r...(a)rcblue.com> wrote:
>> I didn't check on all of them, but the only one I found was Mark
>> Hammond <http://starship.python.net/crew/mhammond/>.
>> Dick Moores
> Doing 6 random clicks, revealed:
> all the others are dead links. I realised this fact as well some time
> ago already. I thought the page itself was still "in development" and
> did not find a single one page. These two obviously eluded me ;)
There are actually 20 active links, different from the error default.
Ok, this is not the best result for a total of 273 members.
> Strange to see that the situation did not yet improve. But then again,
> we all probably know how much of a hassle it is to keep 10 different
> web-pages with personal info's up-to-date. I suppose that the starship
> crew all have som homes elsewhere and don't find the time to update
> yet another page.
No, I think the Starship lost a lot of its popularity after a couple
of havaries, and its initiator failed to lead it and to push it
further. I think this is something that needs to be done by somebody.
There was a couple of very helpful supporters, but they were all
on their own, and the originally driving person did not care
any longer for many years. This has changed.
> I myself don't even bother anymore at all. I have
> about 2 hours of free time per day (given that I like to sleep a
> lot!). What makes things worse, the network at work is completely cut
> off from the rest of the world for security reasons. I am happy that I
> at least can access usenet by using google-groups *sigh*.
So you have HTTP access?
Then ask the starship to support that!
I will take care!
> An interesting task might be to find the homes of the starship crew,
> and post them here? Maybe? If lucky, the right person picks this up
> and updates the crew-quarter labels of the starship. Or would
> "Turbolift Buttons" be a better analogy for hyperlinks? Args.
> Supposing, that these turbolifts *do* have buttons. How retro! ;)
The Starship has gone through quite some problems and different hands.
They all were good, and I wish to thank Stefan Drees especially
for hosting it alone for four years from his personal budget.
Not to forget the years where we were hosted by zope.org, and
beopen.com, and some Service created by Mike Mc. Lay before.
Please excuse me, the I don't remember all the details, this
will go into a history page or blog ASAP.
After a long journey through space and time, I am getting back at
my roots, and I want to fill the gap of a driving person, again.
This is not selfish in any way, and not saying that it must be
me at all, but somehow I feel the wish to bring something to
a working future that I started long time ago.
I invented, created and hosted the Starship, ten years ago.
Now I think, after spending a lot of time with other projects
like Stackless Python and PyPy, time has come to redo the Starship
idea, which was my first contribution for the Python community,
a time where I was not able to really contribute by code.
Especially, I could not work on the Python core because I was no
C programmer. So I created Starship, learned C, understood all
the internals and invented Stackless.
But after all, I think I owe the Starship a lot, and I want it to
continue, and to become a valued resource, again. As a starter,
I moved the ship to my stackless server, this time using OpenVZ.
This transfer worked much smoother than expected; I consider
OpenVZ a great piece of software.
The Starship is therefore right now not very different from its
outside view, it was just moved and upgraded. That is just the
beginning. To turn it into a resource of desire, again, a row
of improvements are necessary.
My personal vision, amoung new projects, is to split my time
between Starship, Stackless and PyPy. If that works depends
on the goodwill of sponsors. But it has worked, so I believe it
will work, again.
Here is an incomplete list of things that I want to do or initiate.
First, I want to revive as many as crew homes that are archived.
This will fill the tiny list from above, reasonably, and probably
it will result in people updating their outdated pages.
Then, I want to split the Starship into many sub-sites, first
on my server, then by using a lot of more servers. I am seeking
for sponsors who are willing to support this.
In the end, my vision is turning python.net into a real network
of many servers, each running a very small number of services
through openVZ. Python.net should be something like a server farm,
which runs everything available in Python. Really everything,
including the myriads of possible PyPy builds.
I want to separate all of these things by utilizing OpenVZ,
as fine-grained as makes sense. I am investigating this these days.
Right now, the Starship is a single VE. It will turn into a growing
set of smaller VE's in the next weeks. And as soon as we get
sponsorship, python.net will split itself over multiple machines.
After all, my vision is to create the ultimate Python showdown,
running everything possible in isolated environments and allowing
people to play with different configurations.
python.net should become the ultimate python resource site
for interactive playing and trying, and providing a home for
people to show their development.
I will also try to get the PSF interested in that; maybe there
is also some PSF funding possible. But this is an option, I
will continue Starship without support as well.
I believe I can do that, with your help.
feeling stronger than before that stroke attack -- sincerely - chris
This is much more work than I can do alone. Therefore, I am asking
for people to help me with this.
I also don't want to miss any of the current supporters, and we will
name them all on the revised contributors pages to come.
In order to support really many Python projects, we will need
not only sponsors, but probably the support of the individual
project maintainers as well. I am open to make this my goal
of life, if there are enough people interested.
But they will, I know it.
I do believe in Python, Starship, PyPy and Stackless.
Please help me to make this life-dream into reality.
happily being back to the roots -- chris
Christian Tismer :^) <mailto:email@example.com>
tismerysoft GmbH : Have a break! Take a ride on Python's
Johannes-Niemeyer-Weg 9A : *Starship* http://starship.python.net/
14109 Berlin : PGP key -> http://wwwkeys.pgp.net/
work +49 30 802 86 56 mobile +49 173 24 18 776 fax +49 30 80 90 57 05
PGP 0x57F3BF04 9064 F4E1 D754 C2FF 1619 305B C09C 5A3B 57F3 BF04
whom do you want to sponsor today? http://www.stackless.com/
On 05/10/2007, Bill Janssen <janssen(a)parc.com> wrote:
> For some reason, it was set to be 'hidden'.
Tiny typo in setup.py (see below). I've fixed it in my copy - it won't
affect the Windows builds, unless you want to release a new version,
when the version number will change :-)
--- setup.py.orig 2007-10-05 00:19:04.000000000 +0100
+++ setup.py 2007-10-05 19:01:27.359375000 +0100
@@ -160,7 +160,7 @@
ssl_incs = [os.environ.get("C_INCLUDE_DIR") or
ssl_libs = [os.environ.get("C_LIB_DIR") or
libs = ['ssl', 'crypto', 'wsock32']
- if static:
+ if not dynamic:
libs = libs + ['gdi32', 'gw32c', 'ole32', 'uuid']
link_args = ['-static']