New Python User Question about Python.

Grant Griffin not.this at
Fri Aug 24 20:48:12 CEST 2001

In article <mailman.998606076.30996.python-list at>, Chris says...
>As impressed as I am by Tim Peters, I imagine it would be more than a
>single Tim-year to get the job done!

<intentional tease to attract developers>

I dunno...

I'm only fractionally as smart in Tim, and I'm _totally_ inexperienced in
compilers.  But in my spare time lately, I've been working on a system--which I
hope to share with everybody soon--which will meet many of these needs.  And if
somebody _really_ smart like Tim (or the rest of you folks) got interested, I
think it could really go somewhere.

The key to it is a paradigm shift.

My favorite example of a paradigm shift is the common dishwashing machine.  If
you asked somebody to invent a dishwasher (and they had never seen one), the
first thing the would probably think of is making a machine that washes dishes
the way people do--by somehow mechanically scrubbing the dishes with a dish rag.
But then, after thinking about it for a few seconds they'd realize that it could
never be made to work.  Sure, plates are easy, but how the heck do you wash
glasses and silverware?  Then, they might even conclude that a dishwasher was
impossible.  The more experienced folks might say, "Of course, the mechanical
dishwasher idea has been brought up many times before, and it just isn't
feasible for the following very good reasons X, Y, and Z."  And they'd be right:
as imagined, it just isn't feasible (though I saw dog-washing machine in a Three
Stooges movie once which comes pretty close <wink>.)

Yet deep in our hearts, we all just _know_ there's _gotta_ be a way to make a
dishwasher.  The fact that nobody has figured out how to do it doesn't change
that.  (BTW, this sort of deep-in-the-heart thinking is what led Edison to
persist for years in the dark before he succeeded in making the first practical
light bulb.)

Of course, anybody who knows how a dishwasher works knows that it's actually
quite simple--once you adopt the right paradigm.  Details differ, but basically
all dishwashers work by spraying high-pressure water at the dishes.  (Oh, and
they also have a human attached to do loading, unloading, and pre-washing

Likewise, video recorders seemed to be impossible for the first decade of
television.  The only way to record TV shows was to film a TV screen!  They
recognized early-on that the problem was that you couldn't get the videotape to
move fast enough to capture a video signal without breaking the tape.  Was the
answer to make the tape stronger, or maybe to design better mechanics? 
No--somebody eventually figured out the right paradigm: run a _wide_ tape
_slowly_ across a tiltated head rotating at _high speed_.  (Doh!  <head slap!>)

What was the question?  Oh--I remember: Python compilers.  The key is to stop
trying to invent little mechanical washcloth thingies that are supposed to scrub
the source code, and begin to spray high-pressure water at it.  Also, stop
trying to speed up the tape, and work on speeding up the head.

Everybody still lost?  Good--if you got this far, that means I've held your
interest <wink>.

Ok, here's a hint.  From a user's point of view, dynamic typing is useful
primarily for doing generic programming.  (The benefit of not having to declare
variables is just incidental.)  For example, I was delighted and amazed early-on
when I discovered that some Python code I'd written to work on lists
accidentally worked just as well on a Numeric array.  Cool!

For example, consider the humble "average" function.  We all know the algorithm
by heart:

   >>> def avg(x):
   ...    sum = 0.0
   ...    for element in x:
   ...       sum += element
   ...    return sum / len(x)
   >>> x = [0, 1, 2, 3, 4, 5]
   >>> avg(x)
   >>> 2.5

In Python, this function works equally well for lists, tuples, arrays, or
Numeric arrays full of integers, floats, or longs (except that it always returns
a float--darn!)  That's beautiful.  But in all honesty, how often do you really
_need_ to do generic programming?  I'm guessing, only a very small fraction of
the time--1%, maybe?  Most of the time, you (the programmer) really do know what
types you're working with--even if Python doesn't, not because Python's stupid,
but because it's not as smart as you, and you haven't told it (which, if you
think about it, isn't really the smartest thing you ever did <wink>.)

Dynamic typing always comes at a cost (overhead), in order to give you a benefit
which--in the vast majority of cases--you don't need and can't even use, that
is, generic programming.  (But at least you don't have to declare variables

OK, so what if a system already existed that provided the benefits of generic
programming (when you _do_ need it), without the overhead?  What if that system
wasn't Python, but, with a little work (a _lot_ of work actually--that's why I
need your help!), could be made to _seem_ like Python?

I'm seeing a speed factor that ranges from about 1:1 to 70:1, depending on the
algorithm.  Also, as compiled programs, my executables are a lot smaller than
equivalent "frozen" Python programs, and are *much* harder to de-compyle.

If you've figured out what I'm up to, please consider becoming a co-developer. 
(Oh, and *please* don't be the first to blab <wink>.)

</intentional tease to attract developers>

   -what-kind-of-snake-oil-is-in-the-trough-ly y'rs,



Grant R. Griffin                                       g2 at
Publisher of dspGuru                 
Iowegian International Corporation  

More information about the Python-list mailing list