mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +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:
@@ -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
|
||||
Reference in New Issue
Block a user