On 19 jan, 10:52, Santiago Caracol <santiago.cara...@gmail.com> wrote:
(snip)
> Whenever one wants to see the list of all (461) mobile phones in the
> admin interface, the development server becomes very slow and
> eventually breaks down with a memory error. Below is the class
> MobilePhone. What can I do?


>     def variants(self):
>         self.save()
>         paraphrases = self.paraphrase()
>         for paraphrase in paraphrases:
>             paraphrases.append(self.producer.name + ' ' + paraphrase)

modifying a list inplace while iterating over it is probably not a
good idea:

source = list("abc")
for item in source:
    print item
    source.append(item + item)
    print source
    if raw_input("got it ? ") == "ok":
        break


a
['a', 'b', 'c', 'aa']
got it ? n
b
['a', 'b', 'c', 'aa', 'bb']
got it ? n
c
['a', 'b', 'c', 'aa', 'bb', 'cc']
got it ? n
aa
['a', 'b', 'c', 'aa', 'bb', 'cc', 'aaaa']
got it ? n
bb
['a', 'b', 'c', 'aa', 'bb', 'cc', 'aaaa', 'bbbb']
got it ? n
cc
['a', 'b', 'c', 'aa', 'bb', 'cc', 'aaaa', 'bbbb', 'cccc']
got it ? n
aaaa
['a', 'b', 'c', 'aa', 'bb', 'cc', 'aaaa', 'bbbb', 'cccc', 'aaaaaaaa']
got it ? ok


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to