Hi all,

I'd happy to have you share some thougts about ultimate optimisations
on those 2 topics:

(1)- adding one caractere at the end of a string (may be long)
(2)- in a dict mapping a key to a list of int, remove every entrie
where the list of int have of length < 2


So far, my attempts are
for (1): 
>>>longone=longone + char # where len(char)== 1
I known that string concatenation is time consuming, but a small test
on timeit seems to show that packing and creating an array for those 2
elements is equally time consuming


for (2):
for k in hash.keys()[:]: # Note : Their may be a lot of keys here
   if len(hash[k])<2:
      del hash[k]


Here again, I think the hash.keys duplication can be time *and* memory
consuming. But still better than (I suppose - no time it yet)
hash=dict([(k,v) for (k,v) in hash if len(v)>1])


I know that I can experiment further with timeit, but still would like
to hear from your experience.

Thanks ! 

--OPQ
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to