summaryrefslogtreecommitdiff
path: root/docs/markdown/Python-module.md
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2024-11-07 12:12:10 +0100
committerJussi Pakkanen <jpakkane@gmail.com>2025-03-01 16:40:58 +0200
commit0ce21ac78a09e70735ba63e873ac8587a41af140 (patch)
tree78bd3bf9e720703c3ab4866103a8179669217c3e /docs/markdown/Python-module.md
parent25abe40343d549d0fa5e6e50a09ce05647e3145a (diff)
downloadmeson-0ce21ac78a09e70735ba63e873ac8587a41af140.tar.gz
arglist: optimize flush_pre_post(), and __iadd__() with it
Unless an argument is marked as Dedup.OVERRIDDEN, pre_flush_set and post_flush_set will always be empty and the loops in flush_pre_post() will not be doing anything interesting: for a in self.pre: dedup = self._can_dedup(a) if a not in pre_flush_set: # This just makes new a copy of self.pre new.append(a) if dedup is Dedup.OVERRIDDEN: # this never happens pre_flush_set.add(a) for a in reversed(self.post): dedup = self._can_dedup(a) if a not in post_flush_set: # Here self.post is reversed twice post_flush.appendleft(a) if dedup is Dedup.OVERRIDDEN: # this never happens post_flush_set.add(a) new.extend(post_flush) In this case it's possible to avoid expensive calls and loops, instead relying as much on Python builtins as possible. Track whether any options have that flag and if not just concatenate pre, _container and post. Before: ncalls tottime cumtime 45127 0.251 4.530 arglist.py:142(__iter__) 81866 3.623 5.013 arglist.py:108(flush_pre_post) 76618 3.793 5.338 arglist.py:273(__iadd__) After: 35647 0.156 0.627 arglist.py:160(__iter__) 78998 2.627 3.603 arglist.py:116(flush_pre_post) 73774 3.605 5.049 arglist.py:292(__iadd__) The time in __iadd__ is reduced because it calls __iter__, which flushes pre and post. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'docs/markdown/Python-module.md')
0 files changed, 0 insertions, 0 deletions