Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use DataClass to store stats #3084

Open
nicolargo opened this issue Jan 11, 2025 · 2 comments
Open

Use DataClass to store stats #3084

nicolargo opened this issue Jan 11, 2025 · 2 comments

Comments

@nicolargo
Copy link
Owner

Use data class as default data:

  • for stats history
  • for all "real time stats"

Resources:

@nicolargo
Copy link
Owner Author

nicolargo commented Jan 11, 2025

Ex:

>>> from pydantic import BaseModel
>>> class Toto(BaseModel):
...     value: int
...     key: str
>>> i = Toto(key="cpu", value=10)
>>> i
Toto(value=10, key='cpu')
>>> i.model_dump_json()
'{"value":10,"key":"cpu"}'
>>> i.model_dump()
{'value': 10, 'key': 'cpu'}

>>> d =  i.model_dump()
>>> import sys
>>> sys.getsizeof(i)
72
>>> sys.getsizeof(d)
184

@nicolargo
Copy link
Owner Author

First step is to create a DataClass catalog with all the class used by Glances Stats.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant