Re: [Python-Dev] 2.4 news reaches interesting places

2004-12-08 Thread Andrew McGregor
Well, for a lot of applications for Python, the performance that really  
counts is time from no code but a pile of data to code and processed  
data.  Python shines at that because nearly always the time to write  
the code dominates, so it doesn't matter what the run time is.

I wrote a little tool to translate a bunch of free data into scenery  
for the X-Plane flight simulator.  If I'd tried to do it in C, I'd  
still be debugging it, whereas I released it and the scenery I was  
building six months ago.  The run time of the C version would be, I  
speculate, about 5 times faster than the Python (given that psyco  
speeds it up about 8 times, and I would not have been so fancy with the  
algorithms in C).  But a 5x improvement on a 24 hour runtime is not 6  
months of improvement.

The other thing we can do is finish the portable backend for psyco and  
make it a standard module.  Then Python won't be slow, it will be  
compiled, and py2exe will be able to make a single-file executable.

Andrew
On 9/12/2004, at 11:18 AM, Guido van Rossum wrote:
I was pleasantly surprised to find a pointer to this article in a news
digest that the ACM emails me regularly (ACM TechNews).
http://gcn.com/vol1_no1/daily-updates/28026-1.html
One thing that bugs me: the article says 3 or 4 times that Python is
slow, each time with a refutation ("but it's so flexible", "but it's
fast enough") but still, they sure seem to harp on the point. This is
a PR issue that Python needs to fight -- any ideas?
--  
--Guido van Rossum (home page: http://www.python.org/~guido/)
___
Python-Dev mailing list
[EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:  
http://mail.python.org/mailman/options/python-dev/ 
andrew%40indranet.co.nz


___
Python-Dev mailing list
[EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Re: switch statement

2005-04-21 Thread Andrew McGregor
I can post an alternative, inspired by this bit of Haskell (I've  
deliberately left out the Haskell type annotation for this):

zoneOpts argv =
   case getOpt Permute options argv of
  (o,n,[]) -> return (o,n)
  (_,_,errs) -> error errs
which could, in a future Python, look something like:
def zoneOpts(argv):
case i of getopt(argv, options, longoptions):
i[2]:
raise OptionError(i[2])
True:
return i[:2]
The intent is that within the case, the bit before each : is a boolean  
expression, they're evaluated in order, and the following block is  
executed for the first one that evaluates to be True.  I know we have  
exceptions for this specific example, but it's just an example.  I'm  
also assuming for the time being that getopt returns a 3-tuple  
(options, arguments, errors) like the Haskell version does, just for  
the sake of argument, and there's an OptionError constructor that will  
do something with that error list..

Yes, that is very different semantics from a Haskell case expression,  
but it kind of looks like a related idea.  A more closely related idea  
would be to borrow the Haskell patterns:

def zoneOpts(argv):
case getopt(argv, options, longoptions):
(o,n,[]):
return o,n
(_,_,errs):
raise OptionError(errs)
where _ matches anything, a presently unbound name is bound for the  
following block by mentioning it, a bound name would match whatever  
value it referred to, and a literal matches only itself.  The first  
matching block gets executed.

Come to think of it, it should be possible to do both.
Not knowing Ocaml, I'd have to presume that 'match' is somewhat similar.
Andrew
On 21/04/2005, at 9:30 PM, Michael Hudson wrote:
Shannon -jj Behrens <[EMAIL PROTECTED]> writes:
On 4/20/05, M.-A. Lemburg <[EMAIL PROTECTED]> wrote:
My use case for switch is that of a parser switching on tokens.
mxTextTools applications would greatly benefit from being able
to branch on tokens quickly. Currently, there's only callbacks,
dict-to-method branching or long if-elif-elif-...-elif-else.
I think "match" from Ocaml would be a much nicer addition to Python
than "switch" from C.
Can you post a quick summary of how you think this would work?
Cheers,
mwh
--  
  We did requirements and task analysis, iterative design, and user
  testing. You'd almost think programming languages were an interface
  between people and computers.-- Steven Pemberton
  (one of the designers of Python's direct ancestor ABC)
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:  
http://mail.python.org/mailman/options/python-dev/ 
andrew%40indranet.co.nz


___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com