From b2137e3bf1634cc090684767186c76773f6033f5 Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Tue, 23 Nov 2021 11:41:34 -0500 Subject: [PATCH] [+] Give detailed explanation for named tuple --- src/process/twitter_process.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/process/twitter_process.py b/src/process/twitter_process.py index 8e0d38f..bda9a64 100644 --- a/src/process/twitter_process.py +++ b/src/process/twitter_process.py @@ -10,9 +10,13 @@ from dataclasses import dataclass class UserPopularity(NamedTuple): """ - User and popularity (we use NamedTuple instead of dataclass because named tuples are easier to - serialize in JSON and they require much less space in the stored json format because no key info - is stored). + User and popularity. + + We use NamedTuple instead of dataclass because named tuples are easier to serialize in JSON and + they require much less space in the stored json format because no key info is stored. For + example, using dataclass, the json for one UserPopularity object will be: + {"username": "a", "popularity": 1, "num_postings": 1}, while using NamedTuple, the json will be: + ["a", 1, 1], which saves an entire 42 bytes for each user. """ # Username username: str