Inefficiency of __getattr__

Kragen Sitaker kragen at dnaco.net
Thu Oct 5 01:09:38 EDT 2000


In article <8rf3fm030n4 at news2.newsguy.com>,
Alex Martelli <aleaxit at yahoo.com> wrote:
>"Kragen Sitaker" <kragen at dnaco.net> wrote in message
>news:NpzC5.1605$l52.81889 at news-west.usenetserver.com...
>    [snip]
>> So what's the advantage of static typing over dynamic typing?  Does it
>> help you catch bugs, and if so, which ones?
>
>It helps catch some type-related bugs -- particularly in areas
>of the code that it's hard to ensure are wholly tested because
>they deal with rare/exceptional/abstruse conditions.  Even for
>bugs one would catch anyway in testing, it does help by letting
>you do the "catching" earlier -- costs are lower the earlier
>you catch the bugs.

I run my regression tests after the compile.  For functional stuff, it
tends to be pretty fast --- a second or less per thousand lines of
code.  My web stuff is slower.  That's not much of an earliness advantage ;)

>It also helps your compiler generate better code.  And, your
>source can be more expressive, as it states certain things that
>you know about your code, in a precise and unambiguous way.

I agree with generating better code; static typing definitely makes
writing good compilers easier.

It *does* state certain things that you know about your code in a
precise and unambiguous way.  The problem is that they are things that
are minimally related to the problem at hand.  It makes your source
code "more expressive" in the same way that assembler is "more
expressive" than C: assembler is five times as long, and precisely and
unambiguously describes which registers you are using and what order
you are computing operations in.

But you have convinced me that it is useful, at least, to describe what
interface you require of your parameters.  STL seems to have gone
furthest in this direction.
-- 
<kragen at pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Perilous to all of us are the devices of an art deeper than we ourselves
possess.
                -- Gandalf the Grey [J.R.R. Tolkien, "Lord of the Rings"]





More information about the Python-list mailing list