Python is too fast !

Cameron Laird claird at lairds.com
Sat Feb 21 10:27:10 EST 2004


In article <8089854e.0402210039.5b761d0f at posting.google.com>,
Fuzzyman <michael at foord.net> wrote:
>I've written an anagram finder that uses recursion and a large
>wordlist to find anagrams of input words you give it (e.g. 'michael
>food' = 'cool firm head') ;-)
>
>http://www.voidspace.org.uk/atlantibots/nanagram.html
>
>It has a nice Tkinter front end and works very well, *except* if you
>give it a long input it takes a long time to process (as might be
>expected) - ten minutes or more sometimes before it returns with the
>answers.
>
>I've done a CGI version which returns the answers *whilst* it is
>finding them ( http://www.voidspace.xennos.com/cgi-bin/Nanagram-CGI.py
>) - which is a much slower method, but less boring to watch.
>
>So I've coded an option - which opens a temporary window with a
>Tkinter text widget in a frame and outputs the answers to the window
>as it finds them. The trouble is that the recursion is very processor
>intensive and it 'freezes' the window and it doesn't update. (I'm
>running on an AMD XP1700 with Win XP).
>
>*If* I run this from IDLE and put a print statement into the loop as
>well as output to the text widget, then the print statement seems to
>free up the widget and it works as it should. I suspect that the print
>statement is making system calls which free up the system long enough
>to update the screen. When I run it without a console - the benefit is
>lost and it freezes again. However I've tried adding a sleep statement
>( 0.001, 0.01 and even 0.1 of a second) and this has no effect (other
>than slowing down the loop without unfreezing the window).
>
>I'm looking for another suggestion to 'waste time' - preferably in a
>'non-processor-intensive' way, that returns control to the sytem for
>an instant ? (also preferably cross platform).
			.
			.
			.
1.  I haven't looked at your code.
2.  I think you're describing an aspect of Tkinter
    programming that's puzzled many of us.  Calling
    it a way to "waste time" probably doesn't get
    your point across, though.
3.  The simple-minded answer I believe you're after
    is:  use update() <URL:
http://www.pythonware.com/library/tkinter/introduction/x9374-event-processing.htm >
4.  The Tk crowd has a lot to say on this subject
    <URL: http://wiki.tcl.tk/1526 >.
-- 

Cameron Laird <claird at phaseit.net>
Business:  http://www.Phaseit.net



More information about the Python-list mailing list