Turing Compliant?

Tim Peters tim_one at email.msn.com
Sat Sep 4 02:40:06 EDT 1999


[Kristopher Johnson]
> But can Python efficently solve the Traveling Salesman Problem,
> or other NP-complete problems?

If it were thought possible to solve such things efficiently, they wouldn't
be NP-complete <0.5 wink>.

TSP in particular has had person-centuries of intellectual effort tossed at
it, and the best algorithms known will certainly run faster in almost
anything other than Python.

OTOH,

1) If you're looking to write a nice framework in which to enter, visualize,
and report TSP problems & results, Python can do everything including
dynamically generate optimized native machine code tailored to each problem
instance (if you're looking for peak efficiency, anything less is wimpy
compromise <wink>).

2) For problems that haven't yet been studied to distraction, a language
like Python (other very high level languages fit here too, but Python is
particularly well suited to this) lets you try out dozens of approaches with
little effort.  Over the years I've found hard-problem heuristics that
allowed my Python program to run 1000x faster than a colleague's
micro-optimized C, because I can code up & test 20 approaches in the time it
takes them to remember how to declare a vector of functions returning a
vector of pointers to pointers to structs <0.9 wink>.

> That's the true measure of a language

It's one measure of many, and Python does fine here.

> (other than being able to compile its own compiler, of course).

Which is another measure of many.  It's too easy for Python to bother to
compile itself, so it usually compiles Perl instead <wink>.

ok-ok-perl-can't-even-be-parsed-ly y'rs  - tim






More information about the Python-list mailing list