[Python-Dev] Slice as a copy... by design? (original) (raw)

Facundo Batista facundobatista at gmail.com
Thu May 22 18:34:56 CEST 2008


2008/5/22 Isaac Morland <ijmorlan at cs.uwaterloo.ca>:

By contrast, the worst that can happen with no sharing is that performance and memory use is what you expect - the only "bad" is the apparent missed opportunity for optimization.

Exactly, "apparent".

Also, this could be handled like a "good writing tip". For example, right now everybody knows that appending a letter to a string a zillion times is not efficient, you should store them in a list, and then .join() them.

Similarly, we could know that slicing zillions of long lines and keeping small portion of them is not memory efficient, you should do everytime "shortstring = str(longstring[:2])", for example. Note that this "special coding" will be for an "special case"... in your normal life the code just will be more efficient...

Regards,

-- . Facundo

Blog: http://www.taniquetil.com.ar/plog/ PyAr: http://www.python.org/ar/



More information about the Python-Dev mailing list