From f8c0e80cfc4011071ad4f3e8a7b590cf8520e85f Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Wed, 1 May 2019 14:23:16 -0400 Subject: [PATCH] add __slots__ to BlobInfo, StreamDescriptor, and KademliaPeer --- lbrynet/blob/blob_info.py | 7 +++++++ lbrynet/dht/peer.py | 9 +++++++++ lbrynet/stream/descriptor.py | 11 +++++++++++ 3 files changed, 27 insertions(+) diff --git a/lbrynet/blob/blob_info.py b/lbrynet/blob/blob_info.py index d300fd905..febfdcb65 100644 --- a/lbrynet/blob/blob_info.py +++ b/lbrynet/blob/blob_info.py @@ -2,6 +2,13 @@ import typing class BlobInfo: + __slots__ = [ + 'blob_hash', + 'blob_num', + 'length', + 'iv', + ] + def __init__(self, blob_num: int, length: int, iv: str, blob_hash: typing.Optional[str] = None): self.blob_hash = blob_hash self.blob_num = blob_num diff --git a/lbrynet/dht/peer.py b/lbrynet/dht/peer.py index 9c8176eb5..23bc29635 100644 --- a/lbrynet/dht/peer.py +++ b/lbrynet/dht/peer.py @@ -135,6 +135,15 @@ class PeerManager: class KademliaPeer: + __slots__ = [ + 'loop', + '_node_id', + 'address', + 'udp_port', + 'tcp_port', + 'protocol_version', + ] + def __init__(self, loop: asyncio.BaseEventLoop, address: str, node_id: typing.Optional[bytes] = None, udp_port: typing.Optional[int] = None, tcp_port: typing.Optional[int] = None): if node_id is not None: diff --git a/lbrynet/stream/descriptor.py b/lbrynet/stream/descriptor.py index a2f4d1da2..2b0527d35 100644 --- a/lbrynet/stream/descriptor.py +++ b/lbrynet/stream/descriptor.py @@ -47,6 +47,17 @@ def file_reader(file_path: str): class StreamDescriptor: + __slots__ = [ + 'loop', + 'blob_dir', + 'stream_name', + 'key', + 'suggested_file_name', + 'blobs', + 'stream_hash', + 'sd_hash' + ] + def __init__(self, loop: asyncio.BaseEventLoop, blob_dir: str, stream_name: str, key: str, suggested_file_name: str, blobs: typing.List[BlobInfo], stream_hash: typing.Optional[str] = None, sd_hash: typing.Optional[str] = None):