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:
+1
-1
@@ -1662,7 +1662,7 @@ def compile(fields_, results,
|
|||||||
|
|
||||||
# lazily fold results
|
# lazily fold results
|
||||||
return self.__class__.__mro__[1].__new__(self.__class__, **(
|
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(
|
| {k: extend(
|
||||||
object.__getattribute__(self, k),
|
object.__getattribute__(self, k),
|
||||||
object.__getattribute__(other, k))
|
object.__getattribute__(other, k))
|
||||||
|
|||||||
Reference in New Issue
Block a user