diff options
| author | Denis Ledoux <dle@odoo.com> | 2019-02-04 13:57:22 +0000 |
|---|---|---|
| committer | Raphael Collet <rco@odoo.com> | 2019-02-11 15:45:36 +0000 |
| commit | 368751b9389ea652cffc7864adef66aac59986d9 (patch) | |
| tree | 5251bc0d4471306549e7349bc6cf0ae2e5572582 /odoo/api.py | |
| parent | 600c8b3e65e552113df330b0436999e54a437ff9 (diff) | |
[IMP] api: avoid `record.id` indirections
The cache is quite time critical, as it is accessed millions times when reading
multiple fields on hundred of thousands of records.
Avoiding indirections and `if` statement when possible speeds up the cache
access time.
Diffstat (limited to 'odoo/api.py')
| -rw-r--r-- | odoo/api.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/odoo/api.py b/odoo/api.py index ca9927739a5..1bf9ba05f90 100644 --- a/odoo/api.py +++ b/odoo/api.py @@ -964,13 +964,13 @@ class Cache(object): def get(self, record, field): """ Return the value of ``field`` for ``record``. """ key = record.env.cache_key(field) - value = self._data[key][field][record.id] + value = self._data[key][field][record._ids[0]] return value.get() if isinstance(value, SpecialValue) else value def set(self, record, field, value): """ Set the value of ``field`` for ``record``. """ key = record.env.cache_key(field) - self._data[key][field][record.id] = value + self._data[key][field][record._ids[0]] = value def remove(self, record, field): """ Remove the value of ``field`` for ``record``. """ |
