diff options
| author | Olivier Dony <odo@odoo.com> | 2020-09-05 00:15:50 +0000 |
|---|---|---|
| committer | Olivier Dony <odo@odoo.com> | 2020-09-05 04:12:52 +0000 |
| commit | 017d1c9de95f12f541438a3ffd5b44d67e93944f (patch) | |
| tree | 09115217c30d1062bb3081d05b5faf15a42a55cd /addons/mass_mailing/models/mailing.py | |
| parent | eff7084d24b86de4b66f3075deffe4f8f06c0a98 (diff) | |
[FIX] mass_mailing: speed up recipients filtering
Using a `set` to lookup recipients that already received an email is
much faster on average than with a list. `x in list` is O(n) on
average, whereas `x in set` closer to O(1) on average.
Example: for a sample mailing with 50k recipients that is half-through,
filtering the remaining half (25k) took 10s with a list, and 1s with
the set.
X-original-commit: 7948698cc6e6b0af5fc84847ea7ec166882eda0b
Diffstat (limited to 'addons/mass_mailing/models/mailing.py')
| -rw-r--r-- | addons/mass_mailing/models/mailing.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/addons/mass_mailing/models/mailing.py b/addons/mass_mailing/models/mailing.py index a756620a4f0..968c0c373b6 100644 --- a/addons/mass_mailing/models/mailing.py +++ b/addons/mass_mailing/models/mailing.py @@ -536,7 +536,7 @@ class MassMailing(models.Model): ('model', '=', self.mailing_model_real), ('res_id', 'in', res_ids), ('mass_mailing_id', '=', self.id)], ['res_id']) - done_res_ids = [record['res_id'] for record in already_mailed] + done_res_ids = {record['res_id'] for record in already_mailed} return [rid for rid in res_ids if rid not in done_res_ids] def _get_unsubscribe_url(self, email_to, res_id): |
