Dynamic features used

Tim Chase python.list at tim.thechases.com
Fri Nov 21 09:08:05 EST 2008


> - What are the dynamic features of Python that you use in your code?
> (excluding ones that can can be done with a good static template
> system).

introspection & dynamic properties are a big one.  Having 
functions and classes as higher-order objects that can be passed 
around like any other variable is quite handy.  There may other 
"dynamic" features that I use but don't have mentally filed as 
"dynamic" so they've been omitted here. :)

> - Are them worth the decrease in running speed?

heck yeah.  I hardly notice any decrease in speed for using 
Python -- most of my bottlenecks are I/O (usually disk, network, 
or database) related and those that are computationally bound, 
it's often a matter of choosing a better algorithm (see several 
threads in the last couple months where the OP was using an 
O(N^2) algorithm that was fairly simply replaced with an O(N) 
algorithm).

For those using a best-case algorithm that are still CPU-bound, I 
haven't found great orders of magnitude speedup in converting 
them to a compiled/non-dynamic language.  I might shave a couple 
seconds off runtime of a couple minutes, but the development 
speed using Python more than makes up for those couple minutes 
most times (most of them are one-off scripts that don't run more 
than a couple times), but my O(N^2) algorithms that can't be 
reduced to exact-matching-using-sets solutions still take 
correspondingly long no matter the language.

> - Is it good for Python to become two languages in one, a fast
> statically typed one and a dynamically one, like pypy shows to like
> with RPython, or is it better to go the way of the Boo language, that
> (while being mostly static) is mixing dynamic and static typing in the
> same code, but that must rely on a very complex virtual machine to
> work?

I think Python walks this line very well, being readily 
embeddable in other programs, and allowing native code-modules to 
be included for inner-loop processes.  While there are some times 
it would be handy to have some static features such as 
compile-time checking, I would only want to turn them on 
optionally, not have them enforced by the language.

My $0.02 taxed for bail-out money...

-tkc









More information about the Python-list mailing list