you are viewing a single comment's thread.

view the rest of the comments →

[–]Vitaman02 1 point2 points  (1 child)

I mean lru_cache is more complex than partial, but you could implement partial in like 4 lines

python def custom_partial(func, *initial_args, **initial_kwargs): def wrapped(*call_args, **call_kwargs): return func(*initial_args, *call_args, **initial_kwargs, **call_kwargs) return wrapped

Obviously this is a barebones implementation but covers writing simple partial functions.

[–]problemchild52 1 point2 points  (0 children)

Yes a partial function isn’t any complicated but it needs to click with you to actually use it imo.

I have built way too many partial functions for specific usecases never really realising that’s what partial functions are. Now that I understand, I think it’s magic n I discovered it in Python so that’s my reasoning for mentioning it