After discussion on Django developers group about
Model.__init__(*args) deprecation I found the way to dramatically
optimize instantiation of Django models. Here is a code: 
http://pastebin.com/m8e7e365

You may add this code to your Django model class and then instead of
obj = YourModelClass(title='Title', ....,
pub_date=datetime.datetime.now() )
use
row = (None, 'Title',..., datetime.datetime.now())
obj = YourModelClass.fromtuple(row) # 1.3x faster then before
or
obj = YourModelClass.fromtuple(row, False) # 3x faster then before
only if you don't need pre_init and post_init signals!

The number of tuple items should be exactly the same that number of
fields.

And, be careful, the code is experimental, untested and relies on deep
black magic of object.__new__(class) which creates the instance
without calling __init__
--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to