r/programminghorror • • Oct 26 '26

Python I love Python

303 Upvotes

81 comments sorted by

View all comments

Show parent comment

29

u/ZylonBane Oct 26 '26

Which defeats the entire purpose of the default value feature.

29

u/notjfd Oct 26 '26

The default value is fine as long as it is not a mutable object. So things like integers and strings are completely fine to use as default values.

-14

u/ZylonBane Oct 26 '26

Yes, we're all aware. Nobody has disputed that.

5

u/shunabuna Oct 26 '26

its probably for optimisation to reduce the amount of instructions needed to initiate a function call. On the plus side, its an easy place to define a cache

-1

u/maikindofthai 28d ago

No? The main purpose is so callers can omit the arg if they’re ok with the default. This still achieves that.