OPQ wrote:
for (2):
for k in hash.keys()[:]: # Note : Their may be a lot of keys here
if len(hash[k])<2:
del hash[k]
- use the dict.iter* methods to prevent building a list in memory. You
shouldn't use these values directly to delete the entry as this could
break the iterator:
for key i
OPQ wrote:
- Try if it isn't faster to iterate using items instead of iterating
over keys
items are huge lists of numbers. keys are simple small strings. And
even if it is faster, how can I find the key back, in order to delete
it ?
for v in hashh.items():
if len(v)<2:
del ???
On 29 Mar 2005 23:41:15 -0800, [EMAIL PROTECTED] (OPQ) wrote:
[...]
>> > for k in hash.keys()[:]: # Note : Their may be a lot of keys here
>> >if len(hash[k])<2:
>> > del hash[k]
>>
>> - Try if it isn't faster to iterate using items instead of iterating
>> over keys
>
>items are huge l
I posted a question about string concatination just last week. There is
plenty of discussion on it, if you just search the group.
--
http://mail.python.org/mailman/listinfo/python-list
#For the record, I'm not on premature optimisation anymore.
#The code is working. I just want to save hours of computing, without
relying to much on C extensions.
#Nevertheless, thansk for tips, clarifications and explanations.
> longone=longone + char # where len(char)== 1
> >
> > I known t
OPQ wrote:
> (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 (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 th
Thanks for the correction. I didn't pause to think as I
wrote that...
-Peter
> -Original Message-
> From: Aaron Bingham [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, March 29, 2005 11:24
> To: Peter Hansen
> Cc: python-list@python.org
> Subject: Re: Optimisation
Peter Hansen <[EMAIL PROTECTED]> writes:
> You've misunderstood the comments about this area.
> String concatenation is *not* "time consuming".
> *Repeated* concatenations *will become very time
> consuming*, along an exponential curve. That's
> what the discussions about O(n^2) are referring
> t
OPQ wrote:
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
- use cStringIO instead
- or append all chars to a list
OPQ wrote:
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)
longone=longone + char # where len(char)== 1
I known that string concatenation is time consuming, but a small test
on timeit seems to sh
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
fo
11 matches
Mail list logo