diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2011-08-01 11:26:09 +1200 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2011-08-01 11:26:09 +1200 |
commit | 675b3133b482492ce5f5f051cf9a01658568c675 (patch) | |
tree | 879bcd5f83e23fee2a54574edac8076bf922347d | |
parent | 43f1c72511e3f68172ea16f742506693b8feff4c (diff) | |
download | mitmproxy-675b3133b482492ce5f5f051cf9a01658568c675.tar.gz mitmproxy-675b3133b482492ce5f5f051cf9a01658568c675.tar.bz2 mitmproxy-675b3133b482492ce5f5f051cf9a01658568c675.zip |
Improve performance of loading flows from a file hugely.
Fell into the "expensive __eq__ method" trap. Oh, Python, you little scamp.
-rw-r--r-- | libmproxy/flow.py | 3 | ||||
-rw-r--r-- | test/test_flow.py | 8 |
2 files changed, 4 insertions, 7 deletions
diff --git a/libmproxy/flow.py b/libmproxy/flow.py index c15f4566..bbdd21a6 100644 --- a/libmproxy/flow.py +++ b/libmproxy/flow.py @@ -193,9 +193,6 @@ class Flow: f.load_state(state) return f - def __eq__(self, other): - return self.get_state() == other.get_state() - def script_serialize(self): data = self.get_state() return json.dumps(data) diff --git a/test/test_flow.py b/test/test_flow.py index ec62f4c8..59c4e5b4 100644 --- a/test/test_flow.py +++ b/test/test_flow.py @@ -170,18 +170,18 @@ class uFlow(libpry.AutoTree): f = tutils.tflow() f.response = tutils.tresp(f.request) state = f.get_state() - assert f == flow.Flow.from_state(state) + assert f.get_state() == flow.Flow.from_state(state).get_state() f.response = None f.error = proxy.Error(f.request, "error") state = f.get_state() - assert f == flow.Flow.from_state(state) + assert f.get_state() == flow.Flow.from_state(state).get_state() f2 = tutils.tflow() f2.error = proxy.Error(f.request, "e2") assert not f == f2 f.load_state(f2.get_state()) - assert f == f2 + assert f.get_state() == f2.get_state() def test_kill(self): s = flow.State() @@ -410,7 +410,7 @@ class uSerialize(libpry.AutoTree): assert len(l) == 1 f2 = l[0] - assert f2 == f + assert f2.get_state() == f.get_state() assert f2.request.assemble() == f.request.assemble() def test_load_flows(self): |