Is Python string immutable?

Steve Holden steve at holdenweb.com
Thu Dec 8 04:35:28 EST 2005


Frank Potter wrote:
> Thank you very much.
> Steve Holden, I post my soucecode at my blog here:
> http://hiparrot.wordpress.com/2005/12/08/implementing-a-simple-net-spider/ 
> <http://hiparrot.wordpress.com/2005/12/08/implementing-a-simple-net-spider/>
> I wish you can read and give me some suggestion.
> Any comments will be appreciated.
> 
Before any intensive scrutiny of the code perhaps you can answer a few 
questions.

1. Are you absolutely sure you have published the code you are running? 
The code you reference has indentation problems that give syntax errors.

2. Why do you continually create new threads when you could have a fixed 
set of threads sharing a list of URLs to scan?

3. What steps have you taken to ensure that the program does indeed 
perform according to its specifications?

It seems to me that this code is a Java program transliterated into 
Python. A more natural way to express the algorithm would be for a 
number of worker threads to share  Queue.Queue of URLs to be visited. 
The only other data structure that would then need locking would be a 
dictionary of URLs that had already been considered.

Overall you appear to be spending large amounts of time locking and 
unlocking things, and creating threads unnecessarily, but you don't 
claim that the algorithm is particularly refined, and it shouldn;t 
affect memory usage.

However, I would like to be sure that the excessive memory usage *is* 
indeed something to do with your program, as I contend, and not some 
buggy aspect of threading, so I await your answers with interest.

regards
  Steve
-- 
Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC                     www.holdenweb.com
PyCon TX 2006                  www.python.org/pycon/




More information about the Python-list mailing list