speed up is_match() of stem/exit_policy.py

I turns out to me, that the following code snipped

        for conn in connections:
          raddr, rport, lport = conn.remote_address, conn.remote_port, conn.local_port
          if policy.can_exit_to(raddr, rport):
            Curr.setdefault(rport, []).append(str(lport) + ':' + raddr)

takes much longer than expected due to the fact, that policy.can_exit() calls is_match() which itself makes a a lot of checks eg.:

    # validate our input and check if the argument doesn't match our address type

    if address is not None:

For a relay having about 5,000 connections and about 100 ExitPolicy rules thoses checks are repeated 500,000 times w/o too much profit, or ?

I do wonder if is_match() could get a wrapper which just does the given address+port test against the exit policy ?