scripts: csv.py: Fixed bottleneck from overlapping by/from fields

Found from some confusing behavior when by/from fields overlap. It turns
out when this happens (-bhi -Fhi, for example), the generated getattr
for the by field would trigger the __getattribute__ for the overlapping
field field, resulting in a fold on _every add operation_.

Hopefully you can see where this is a bit of a problem when summing a
large number of results (O(n^2)?).

---

Fixed by switching getattr to object.__getattribute__ and reconsidering
csv.py's entire design.
This commit is contained in:
Christopher Haster
2026-01-24 04:52:16 -06:00
parent 04b536eb79
commit 49e3b22907
+1 -1
View File
@@ -1662,7 +1662,7 @@ def compile(fields_, results,
# lazily fold results
return self.__class__.__mro__[1].__new__(self.__class__, **(
{k: getattr(self, k) for k in by}
{k: object.__getattribute__(self, k) for k in by}
| {k: extend(
object.__getattribute__(self, k),
object.__getattribute__(other, k))