diff --git a/scapy/base_classes.py b/scapy/base_classes.py index 4f4dc1169bc0ba7dbec52578de22791bb68af959..01f9fb3a264d22701e4b5b3c14ce6177e37096e4 100644 --- a/scapy/base_classes.py +++ b/scapy/base_classes.py @@ -250,5 +250,5 @@ class BasePacket(Gen): ## Packet list base classe ## ############################# -class BasePacketList: - pass +class BasePacketList(object): + __slots__ = [] diff --git a/scapy/layers/inet.py b/scapy/layers/inet.py index 6cc4303db2f0b54811a5b65fd3b45855b22b3f7e..a8a529388045ea7290b2725367e242a92e6b4f8e 100644 --- a/scapy/layers/inet.py +++ b/scapy/layers/inet.py @@ -937,6 +937,7 @@ PacketList.timeskew_graph = new.instancemethod(_packetlist_timeskew_graph, None, ### Create a new packet list class TracerouteResult(SndRcvList): + __slots__ = ["graphdef", "graphASres", "padding", "hloc", "nloc"] def __init__(self, res=None, name="Traceroute", stats=None): PacketList.__init__(self, res, name, stats) self.graphdef = None diff --git a/scapy/layers/inet6.py b/scapy/layers/inet6.py index 9dc92692174248eb6c367ecc11357a7cb067aa6e..63b6f06d39b8da047d60a061b8fc51c4f70d2a8e 100644 --- a/scapy/layers/inet6.py +++ b/scapy/layers/inet6.py @@ -2888,6 +2888,7 @@ class AS_resolver6(AS_resolver_riswhois): return ip,asn,desc class TracerouteResult6(TracerouteResult): + __slots__ = [] def show(self): return self.make_table(lambda (s,r): (s.sprintf("%-42s,IPv6.dst%:{TCP:tcp%TCP.dport%}{UDP:udp%UDP.dport%}{ICMPv6EchoRequest:IER}"), # TODO: ICMPv6 ! s.hlim, diff --git a/scapy/plist.py b/scapy/plist.py index 0308620e9917ebf577ae6b84398775e8f65cd1d9..78b6f4a5ec12ccce361f7d489e29fc35e9c0b54d 100644 --- a/scapy/plist.py +++ b/scapy/plist.py @@ -26,7 +26,7 @@ if arch.GNUPLOT: ############# class PacketList(BasePacketList): - res = [] + __slots__ = ["stats", "res", "listname"] def __init__(self, res=None, name="PacketList", stats=None): """create a packet list from a list of packets res: the list of packets @@ -47,8 +47,7 @@ class PacketList(BasePacketList): def _elt2show(self, elt): return self._elt2sum(elt) def __repr__(self): -# stats=dict.fromkeys(self.stats,0) ## needs python >= 2.3 :( - stats = dict(map(lambda x: (x,0), self.stats)) + stats = dict((x, 0) for x in self.stats) other = 0 for r in self.res: f = 0 @@ -477,6 +476,7 @@ lfilter: truth function to apply to each packet to decide whether it will be dis class SndRcvList(PacketList): + __slots__ = [] def __init__(self, res=None, name="Results", stats=None): PacketList.__init__(self, res, name, stats) def _elt2pkt(self, elt):