Python Forum
len() of ipaddress.ip_network()
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
len() of ipaddress.ip_network()
#7
(May-18-2019, 06:25 AM)perfringo Wrote: EDIT: This question intrigued me, so I went to github to check from rangeobject.c how len of range determined. My knowledge of C is next to none, but:

the point is that it was implemented with C types. to make it work even higher, it needed to be calling the extended precision int code, like it would have to be doing for lots of other things like actual arithmetic -or- implement just the len() part in Python and have the C code call that. i doubt len() would be called too often to consider it a critical point.

slicing a network object would be the next thing. applying [:16] or [-32:] would get a list of one network and applying [8:24] would get a list of two networks since CIDR cannot span that range. or, they implement a network range type object. they did implement the "in" operation, at least for addresses in a network. i should test if network "in" network works.

i am thoroughly familiar with networks and have implement some of this stuff in C. maybe i should implement a subclass with these many added features (just in Python, not C).
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Messages In This Thread
len() of ipaddress.ip_network() - by Skaperen - May-17-2019, 03:49 AM
RE: len() of ipaddress.ip_network() - by heiner55 - May-17-2019, 05:33 AM
RE: len() of ipaddress.ip_network() - by perfringo - May-17-2019, 06:21 AM
RE: len() of ipaddress.ip_network() - by Skaperen - May-17-2019, 07:13 PM
RE: len() of ipaddress.ip_network() - by perfringo - May-18-2019, 06:25 AM
RE: len() of ipaddress.ip_network() - by Skaperen - May-18-2019, 11:14 PM
RE: len() of ipaddress.ip_network() - by DeaD_EyE - May-18-2019, 09:58 AM
RE: len() of ipaddress.ip_network() - by Skaperen - May-19-2019, 12:25 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  module ipaddress Skaperen 2 2,463 Aug-14-2018, 05:59 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020