This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import enum, functools, operator | |
from typing import Self | |
class Color(enum.IntFlag): | |
RED = enum.auto() | |
GREEN = enum.auto() | |
BLUE = enum.auto() | |
@classmethod | |
def from_string_pythonic(cls, string: str) -> Self: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gc | |
import pandas as pd | |
import numpy as np | |
import psutil | |
process = psutil.Process() | |
print(f"pid = {process.pid}") | |
dtypes = ['int64', 'float64', 'complex128', 'object', 'bool'] | |
data = dict([(t, np.ones(shape=0x1000 * 4096).astype(t)) for t in dtypes]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
from typing import List | |
import attr | |
import pandas as pd | |
_log = logging.getLogger(__name__) | |
@attr.s(auto_attribs=True, repr=False, slots=True, hash=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright 2018 Jan-Hein Bührman | |
# | |
# Redistribution and use in source and binary forms, with or without | |
# modification, are permitted provided that the following conditions | |
# are met: | |
# | |
# 1. Redistributions of source code must retain the above copyright | |
# notice, this list of conditions and the following disclaimer. | |
# | |
# 2. Redistributions in binary form must reproduce the above copyright |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SimpleClass: | |
some_int: int | |
some_str: str | |
def __init__(self, some_int: int, some_str: str) -> None: | |
self.some_int = some_int | |
self.some_str = some_str | |
def __repr__(self) -> str: | |
return (f'{self.__class__.__qualname__}' |