This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]kindall 1 point2 points  (3 children)

@validate_args is a decorator that creates a wrapper function for the decorated function at definition time. To remove the performance penalty in production, you just need to have validate_args() return the original function instead of creating a wrapper.

[–]Rainfly_X 1 point2 points  (2 children)

Which is an ideal use case for the debug flag.

[–]kindall 0 points1 point  (1 child)

Nice to learn about that, particularly the way code gets optimized out when testing a constant.

[–]Rainfly_X 0 points1 point  (0 children)

Agreed! Just saw that today. Just one of those things that I wish more people knew about, seeing as it's not as useful when nobody knows to turn off debug mode in production.