Skip to content
This repository was archived by the owner on Jun 12, 2024. It is now read-only.
This repository was archived by the owner on Jun 12, 2024. It is now read-only.

collapse_address_list is too slow #17

@GoogleCodeExporter

Description

@GoogleCodeExporter
What steps will reproduce the problem?
1. Try to collapse a /24's worth of IP addresses one by one.

Below is code used to benchmark
{{{
from ipaddr import IP, CollapseAddrList

import timeit

RUNS = 1000
addresses = [IP(ip) for ip in IP('1.1.1.0/24')]

if __name__ == '__main__':
    t1 = timeit.Timer('CollapseAddrList(addresses)', 'from __main__ import 
CollapseAddrList, addresses')
    print "CollapseAddrList: %s s" % t1.timeit(number=RUNS)
}}}

*Before:*
$ python collapse_timeit.py
CollapseAddrList: 64.273168087 s

*After:*
$ python collapse_timeit.py
collapse: 1.20903706551 s


What is the expected output? What do you see instead?

ipaddr should be faster

What version of the product are you using? On what operating system?

using latest ipaddr trunk version on Ubuntu on 2.6Ghz Core 2 Duo.

Please provide any additional information below.

The patch in http://codereview.appspot.com/67107 adds the following 
functionality derived from my own original IPy based code at 
http://code.google.com/p/wadofstuff/source/browse/trunk/python/ip/wadofstuf
f/ip/summarize.py

1. summarize_address_range() which takes a start and finish IP and 
summarizes that range into networks.
2. Allow IPv4/IPv6 objects to be created using a range notation e.g 
1.1.1.0-1.1.1.7. This is used by summarize_address_range() to shortcut its 
main loop.
3. collapse_address_list will collapse ordered sequences of IP addresses 
and call summarize on them.

Original issue reported on code.google.com by mattimus...@gmail.com on 26 May 2009 at 12:30

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions