New Python User Question about Python.
tanzer at swing.co.at
Sun Aug 26 10:11:21 CEST 2001
Grant Griffin <not.this at seebelow.org> wrote:
[delightful musings skipped]
> 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
Your statement about the rarity of generic programming might apply to
you (although I doubt it) but in general its just plain wrong.
Using generics in Ada or templates in C++ might be difficult for the
average programmer but doing generic programming in Python is so
trivial that just about everybody does it. Every time somebody
reassigns sys.stdout to something which is not a file, they are are
enjoying the benefits of generic programming.
> 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.
Now that certainly sounds interesting. Will your system also allow the
use of generic programming when the need for it was not foreseen by
the original author of the code (for instance, the passing of an
object of a compatible but completely different type as an argument to
If not I'd rather stay with Python.
Christian Tanzer tanzer at swing.co.at
Glasauergasse 32 Tel: +43 1 876 62 36
A-1130 Vienna, Austria Fax: +43 1 877 66 92
More information about the Python-list