#typeddict
What’s the difference between typeddict and pydantic , they look super super similar for simple use cases
November 9, 2024 at 12:13 AM
TypedDict in Python 201: Typisierte Dictionaries richtig nutzen

https://dasgeld.co/posts/46BB9DE9-F787-4D68-B422-7151D124FB0E
September 9, 2025 at 8:53 AM
typing for this is kinda weird bc python dicts are default-homogenous. So you'd need to do a TypedDict and then overload the function signature, like so:

@overload
def deser(data: bytes, disc: Literal['type1']) -> DeserializedType1: ...

and then anywhere the discriminant is provable, ...
January 21, 2025 at 12:03 AM
I'm getting pretty pydantic TypeAdapter-pilled.

It gives you a path towards defining defaults on TypedDict a la Annotated fields, so you can Unpack them into function signatures.

Getting this right _really_ lets you write OSS that folks can truly extend easily.
November 3, 2024 at 3:45 PM
dataclass、TypedDict、pydanticのBaseModelあたりがどう使い分ければいいのかがまだ全然わからん
August 3, 2023 at 2:03 PM
#Python 's #TypedDict is way under valued. It has type features like dynamic type inference, not required (aka undefined/unset), tagged (aka discriminated) unions, and kwarg unpacking (aka destructuring) support. But instead #pydantic and data classes that lack these features are used more today.
July 9, 2025 at 4:38 AM
The big difference is attaching behavior. TypedDict adds definitions, but it wouldn't be idiomatic to have it add behavior. Stuff from `import typing` should all get ignored at runtime.

Dataclasses let you add behavior like `.from_json()` and field validation (a la @attr.s) at runtime
January 3, 2025 at 9:45 PM
from typing import Any, TypedDict

from langchain_core.messages import AnyMessage
from langchain_core.messages.utils import count_tokens_approximately
from langmem.short_term import SummarizationNode
from langgraph.graph import StateGraph, START, MessagesState
June 20, 2025 at 7:29 PM
PythonでTypeScriptみたいなことをしようと思ってdataclass, pydantic, TypedDict, Protocol, metaclassあたりを行ったり来たりするの不毛すぎるのでやめたい
May 26, 2025 at 1:21 AM
A few months ago I discovered TypedDict in Python and I love using it, especially in connection with JSON files. Finally a sane way to document and type hint complex containers. Getting auto-complete suggestions for dict keys is also a neat side effect. #pythonprogramming
May 15, 2025 at 2:35 PM
I recently learned about TypedDict, I haven't used it yet but it seems like a good stop-gap between throwing untyped dicts around vs doing something more "proper"
November 9, 2024 at 12:10 AM
have you ever annotated a TypedDict onto the **kwargs fuction and want Sphinx to automatically add it to the function's docstring?

class GreetingKwargs(TypedDict):
name: Annotated[str, Doc("the name of the person to greet")]

def greet(**kwargs […]

[Original post on scholar.social]
October 3, 2025 at 3:30 PM
Me when I have to touch a ParamSpec or TypedDict.
a young boy is sitting on a couch with his head resting on his hand .
ALT: a young boy is sitting on a couch with his head resting on his hand .
media.tenor.com
April 3, 2025 at 12:28 AM
I've never used pydantic but I think there's some overlap, with typeddict coming later being a PEP-standardized thing
November 9, 2024 at 12:15 AM
I use TypedDict far more than I do dataclasses and classes, mostly because 90% of what I model doesn’t need to have behaviors associated with it (I write lots of data transformations, so I’m usually representing a dataset and doing horrible things to it), and they’re usually singletons anyways
November 9, 2024 at 2:35 AM
Say I have a TypedDict in Python like the following:

class Things(TypedDict):
thing: Literal["thing-role"]
another_thing: Literal["another-role"]

How can I extract all the values so that they can be passed as a type for a function parameter? Is get_type_hints my only resort?

#python
March 15, 2025 at 4:40 PM
LangGraphを使うようになってtyping_extentionsの存在を知ったけどLiteralの処理を使ったときにtypingのLiteralだと予期しない値が返ってきてエラーがでるのが分かった。typingでもLiteralやTypedDictを呼び出せるけどtyping_extentionsを使うようにしてみつつどういう違いがあるのかを理解を深めていきたい。
April 1, 2025 at 2:37 PM
I actually like duck-typing a lot.

Whenever I need to put a structure to a data I send to/get from an API, all I need to do is to cast() the variable into the suitable TypedDict or Protocol and off I go.

That flexibility is head and shoulders better than all the hoops I have to jump through in C#.
February 21, 2024 at 7:58 PM
Нє, ну між нами, то можна і з TypedDict почати і вже буде відчуття, як пил на моніторі протер 👌
January 8, 2024 at 12:02 PM
✨ [NEW POST] Check out our latest post: TypedDict vs Pydantic: Which Should You Use? We explore the differences, benefits, and use cases of TypedDict and Pydantic in Python. www.packetcoders.io/typeddict-vs...
#networkautomation
September 12, 2025 at 2:18 PM
I use TypedDict for everything. It's so great for type safety and documentation.

Heckin hate it whenever I see a method that's like, "This takes a dictionary" and then I have to read the whole source just figure out what keys are expected.
November 9, 2024 at 12:23 AM
TypedDict is purely a type hinter, no runtime behavior. It just lets you pass around json and pretend it's real classes when type checking.

Pydantic is a runtime validator, that ensures your data *actually* matches the declared types.
November 9, 2024 at 1:29 AM
This blog dives deep into the differences between Python’s dataclass, Pydantic, TypedDict, and NamedTuple explaining when and why to use each in backend systems.
#python #learntocode #techblog #programming

hevalhazalkurt.com/blog/datacla...
Dataclasses vs Pydantic vs TypedDict vs NamedTuple in Python
This blog dives deep into the differences between Python’s dataclass, Pydantic, TypedDict, and NamedTuple explaining when and why to use each in backend systems. You'll learn how to choose the right t...
hevalhazalkurt.com
May 26, 2025 at 2:19 PM
I love named tuple and was not aware of that they are sliceable. IMO, they have a lower code footprint than TypedDict and lower cpu/memory dataclasses. I fiddled with a `UnsliceableNT` class which reimplements NamedTuple with `__getitem__` raising an exception. It works. Unsure if it's clean though.
November 27, 2024 at 3:34 AM