mirror of
https://github.com/django/django.git
synced 2025-09-18 00:10:22 +00:00
Fixed #7596. Added Model.objects.bulk_create, and make use of it in several places. This provides a performance benefit when inserting multiple objects. THanks to Russ for the review, and Simon Meers for the MySQl implementation.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16739 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
e55bbf4c3c
commit
7deb25b8dd
22 changed files with 331 additions and 78 deletions
|
@ -275,4 +275,17 @@ class lazy_property(property):
|
|||
@wraps(fdel)
|
||||
def fdel(instance, name=fdel.__name__):
|
||||
return getattr(instance, name)()
|
||||
return property(fget, fset, fdel, doc)
|
||||
return property(fget, fset, fdel, doc)
|
||||
|
||||
def partition(predicate, values):
|
||||
"""
|
||||
Splits the values into two sets, based on the return value of the function
|
||||
(True/False). e.g.:
|
||||
|
||||
>>> partition(lambda: x > 3, range(5))
|
||||
[1, 2, 3], [4]
|
||||
"""
|
||||
results = ([], [])
|
||||
for item in values:
|
||||
results[predicate(item)].append(item)
|
||||
return results
|
Loading…
Add table
Add a link
Reference in a new issue