Re: [OVC-demo-team] Random ballot generator

From: David Mertz <voting-project_at_gnosis_dot_cx>
Date: Sat Mar 06 2004 - 14:05:12 CST

On Saturday, March 6, 2004, at 02:23 PM, Jan Karrman wrote:
>> (1) Append to a list, then join the list at the end:
>> (2) Use cStringIO to buffer lines:

> Thanks for the tips!
> You may recall that I did not know Python at all when I joined the
> project.

Hi Jan,

I do... you've certainly done remarkably great work in a language you
just picked up! Python does make it easier to jump in than most
though. But even so, not many programmers come close to Jan's
achievements.

The string concatenation is a definite pitfall. Coming from a lot of
languages, users tend to think of appending to a string as being
similar to appending to a list/array (it is in lots of languages).
I.e. a list.append() is an O(1) complexity operation (on average, an
occasional more-expensive pre-allocation is needed, but the asymptotic
cost goes to zero). However "s += s2" is an O(N) operation in Python.

> I still haven't read any book on the subject - do you know of any good
> one? ;-)

Well... I *AM* fond of _Text Processing in Python_:
http://gnosis.cx/TPiP/

Btw. If you'd like a copy, Jan, I'd be happy to arrange for my
publisher to send you a review copy. Let me know address information.
The same applies to a limited degree for any other list members (but
especially those with academic-looking addresses).

---[ to our friends at TLAs (spread the word)
]--------------------------
Iran nuclear neocon POTUS patriot Pakistan weaponized uranium invasion
UN
smallpox Gitmo Castro Tikrit armed revolution Carnivore al-Qaeda sarin
---[ Gnosis Software ("We know stuff") <mertz@gnosis.cx>
]---------------
==================================================================
= The content of this message, with the exception of any external
= quotations under fair use, are released to the Public Domain
==================================================================
Received on Thu Apr 1 02:40:25 2004

This archive was generated by hypermail 2.1.8 : Thu Apr 01 2004 - 02:40:36 CST