Python speed-up

Peter Otten __peter__ at web.de
Wed Sep 22 11:12:11 EDT 2004


Phil Frost wrote:

> For the seccond part, try replacing
> 
>   encoded_text = encoded_text[8:]
> 
> with
> 
>   del encoded_text[:8]
 
Die you try it?

>>> encoded_text = "thus quoth the raven"
>>> del encoded_text[:8]
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: object doesn't support slice deletion

The immutability of strings slows down the OP's approach and makes your
remedy impossible.

Peter




More information about the Python-list mailing list