Prototype in Python, Was: A faster Python?, Python compiler, Dylan,...

David M. Cooke cookedm+news at physics.mcmaster.ca
Thu Apr 4 14:11:37 EST 2002


At some point, Jan Kybic <kybic at ieee.org> wrote:

>> your experience gained before tell you that Python slows down
>> remarkably), wouldn't it be wise to implement the function in C or C++
>> from the start on?
>
> If you knew from the beginning what is to be implemented, of course.
> But in real word (especially in the research world), you do not know
> what is going to work. You try something based on your preliminary
> analysis and experience and it does not quite give you the result you
> wanted. So you keep tweaking the algorithm (and implementation) little
> by little, until you are satisfied. For this exploratory programming,
> Python is perfect. You can of course write it directly in C/C++ but if
> the edit/compile/run cycle takes 30s or even more for templated C++
> libraries, you are much less productive. Moreover, you write much more
> in C than in Python.  Once you are satisfied, you want your algorithm
> to run fast. So you rewrite everything into C/C++, having the Python
> implementation as a reference. Not difficult, just takes time.

And the Python code will likely be easier to verify. Once it's working
correctly, rewrite it in C/C++ and run tests to make sure the Python
version and the C version agree.

In general, I find if I'm calculating something which *must* work (or
else I make fool of myself :-), I'll do it twice in two different ways
and languages. It just gives you that extra level of confidence.

-- 
|>|\/|<
/--------------------------------------------------------------------------\
|David M. Cooke
|cookedm(at)physics(dot)mcmaster(dot)ca



More information about the Python-list mailing list