From a3720b0cc68d9b251d0bcbbd2918dd50a39314c5 Mon Sep 17 00:00:00 2001 From: monosans Date: Mon, 11 Apr 2022 12:06:00 +0300 Subject: [PATCH] Add __slots__ attribute to all objects --- CHANGELOG.md | 4 ++++ main.py | 28 +++++++++++++++++++++++++--- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c3c7251..bc83ee3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # YYYY-MM-DD +## 2022-04-11 + +- Add `__slots__` attribute to all objects. + ## 2022-04-08 - Use `|` as geolocation separator. diff --git a/main.py b/main.py index 21d9cfa..1eb9db1 100755 --- a/main.py +++ b/main.py @@ -24,6 +24,14 @@ import config class Proxy: + __slots__ = ( + "socket_address", + "ip", + "is_anonymous", + "geolocation", + "timeout", + ) + def __init__(self, socket_address: str, ip: str) -> None: """ Args: @@ -57,6 +65,8 @@ class Proxy: class Folder: + __slots__ = ("folder_name", "path", "for_anonymous", "for_geolocation") + def __init__(self, folder_name: str, path: Path) -> None: self.folder_name = folder_name self.path = path / folder_name @@ -76,6 +86,20 @@ class Folder: class ProxyScraperChecker: """HTTP, SOCKS4, SOCKS5 proxies scraper and checker.""" + __slots__ = ( + "path", + "all_folders", + "enabled_folders", + "regex", + "sort_by_speed", + "timeout", + "sources", + "proxies", + "proxies_count", + "c", + "sem", + ) + def __init__( self, *, @@ -194,9 +218,7 @@ class ProxyScraperChecker: "http://ip-api.com/json/", timeout=self.timeout ) as r: res = ( - None - if r.status in {404, 429} - else await r.json() + None if r.status in {404, 429} else await r.json() ) except Exception as e: # Too many open files