Repos / mcross / 0265fd4c7f
commit 0265fd4c7f50a6fff0f10fe61e4998df3a225023
Author: Bùi Thành Nhân <hi@imnhan.com>
Date:   Mon May 18 08:39:34 2020 +0700

    use slots

diff --git a/pyproject.toml b/pyproject.toml
index b8dd165..566be1e 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
 [tool.poetry]
 name = "mcross"
-version = "0.5.4"
+version = "0.5.5"
 description = "Do you remember www?"
 authors = ["nhanb <hi@imnhan.com>"]
 license = "MIT"
diff --git a/src/mcross/document.py b/src/mcross/document.py
index d5f6864..821f673 100644
--- a/src/mcross/document.py
+++ b/src/mcross/document.py
@@ -6,6 +6,7 @@
 
 
 class GeminiNode:
+    __slots__ = ("text",)
     text: str
 
     def __init__(self, text):
@@ -36,6 +37,7 @@ class H3Node(GeminiNode):
 
 
 class LinkNode(GeminiNode):
+    __slots__ = ("url", "name")
     url: str
     name: str
 
diff --git a/src/mcross/transport.py b/src/mcross/transport.py
index 0af07a0..1b1d547 100644
--- a/src/mcross/transport.py
+++ b/src/mcross/transport.py
@@ -8,10 +8,6 @@
 MAX_REDIRECTS = 3
 
 
-# Wanted to use a dataclass here but ofc it doesn't allow a slotted class to
-# have fields with default values:
-# https://stackoverflow.com/questions/50180735/how-can-dataclasses-be-made-to-work-better-with-slots
-# Maaaaybe I should just use attrs and call it a day.
 class Response:
     __slots__ = ("status", "meta", "body", "url")
 
@@ -47,6 +43,7 @@ class NonAbsoluteUrlWithoutContextError(Exception):
 
 class GeminiUrl:
     PROTOCOL = "gemini"
+    __slots__ = ("host", "port", "path")
     host: str
     port: int
     path: str