This Python wiki 
(https://wiki.python.org/moin/PythonSpeed/PerformanceTips#Choose_the_Right_Data_Structure)
 
suggests:

* Membership testing with sets and dictionaries is much faster, O(1), than 
searching sequences, O(n). When testing "a in b", b should be a set or 
dictionary instead of a list or tuple.

This may or may not apply to your use case.   There is also more discussion 
in this thread:
http://bytes.com/topic/python/answers/587277-how-much-slower-dict-indexing-vs-list-indexing

I have also found in some of my own cases (not involving m2m models though) 
that dropping down to raw SQL for bulk uploads is fast enough to justify 
doing it; but I am trading off against all the model checks/balances that 
Django provides.

On Thursday, 13 August 2015 04:09:04 UTC+2, yakka...@gmail.com wrote:
>
> I'll run a test with the dict vs list+position counter. I know I saw a 
> speed improvement but I can't remember if that was the only thing I 
> changed. 
>
>
> I'd have to change a lot of code if I change the DB scheme so I'm not 
> wanting to create an intermediate table. I'm going to go down the SQL path. 
> Let me know if you have any suggestions. I'm still a beginner with SQL. 
>
>
> Thanks for your help!!!
>
>
> Brian
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4dab3118-8317-43ea-82a9-e425d4218b1b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to