Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use binary search instead of line search. And Fix '保留地址' issue. #7

Merged
merged 3 commits into from
Nov 21, 2014

Conversation

cadl
Copy link
Contributor

@cadl cadl commented Nov 20, 2014

hi, folks:
I use binary search to replace line search. And I do a simple benchmark. The total query time down to 3.5s from 20s.
The benchmark script like this:

import time
from IP import IPv4Database

db = IPv4Database()


st = time.time()
for i in xrange(0, 256*256*256*256, 17173):
    ip = [0, 0, 0, 0]
    cnt = 0
    while i > 0:
        ip[cnt] = i % 256
        i = i / 256
        cnt += 1
    db._lookup_ipv4('.'.join(map(str, ip)))
en = time.time()

print en - st

And I found a issue. Some IP should be mapped to '保留地址', not 'None', like '0.42.134.0'.

lxyu added a commit that referenced this pull request Nov 21, 2014
Use binary search instead of line search. And Fix '保留地址' issue.
@lxyu lxyu merged commit f2a6624 into lxyu:master Nov 21, 2014
@lxyu
Copy link
Owner

lxyu commented Nov 21, 2014

👍 Awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants