M pyproject.toml => pyproject.toml +1 -1
@@ 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"
M src/mcross/document.py => src/mcross/document.py +2 -0
@@ 6,6 6,7 @@ HEADING_LINE_PATTERN = re.compile(r"^(#{1,3})\s+(.+)$")
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
M src/mcross/transport.py => src/mcross/transport.py +1 -4
@@ 8,10 8,6 @@ MAX_RESP_BODY_BYTES = 1024 * 1024 * 5
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