Tag

singledispatch

0 views collected around this technical thread.

Python Programming Learning Circle
Python Programming Learning Circle
Aug 16, 2022 · Fundamentals

Exploring Useful Python Decorators: @lru_cache, @jit, @do_twice, @count_calls, @dataclass, @singleton, @use_unit, @singledispatch

This article introduces Python decorators, explains how they can modify function behavior, and provides practical examples of eight useful decorators—including @lru_cache, @jit, @do_twice, @count_calls, @dataclass, @singleton, @use_unit, and @singledispatch—along with code snippets that demonstrate their implementation and benefits.

JITcode examplesdataclass
0 likes · 10 min read
Exploring Useful Python Decorators: @lru_cache, @jit, @do_twice, @count_calls, @dataclass, @singleton, @use_unit, @singledispatch
Python Programming Learning Circle
Python Programming Learning Circle
Aug 7, 2021 · Fundamentals

Using functools.singledispatch for Extensible JSON Serialization in Python

The article explains how Python's functools.singledispatch (PEP 443) provides a clean, extensible way to serialize arbitrary objects to JSON, avoiding custom default functions or subclassing JSONEncoder, and discusses alternatives, pitfalls, and related tools such as zope.interface and attrs.

JSONPythonSerialization
0 likes · 6 min read
Using functools.singledispatch for Extensible JSON Serialization in Python