[Python-ideas] Decorator to avoid a mistake

Nick Timkovich prometheus235 at gmail.com
Fri Nov 25 14:21:28 EST 2016


You can do it at run-time, if you so desire, without a measurable
performance hit with a metaclass. Here's a hacky demo:
https://gist.github.com/nicktimko/5f08d6adfa1dbe1319c3bfc715ec0aa4#file-override_guard-ipynb

(Pedants: Any performance hit will be constant-time and probably less than
a stray import that you don't need. If you're worried about optimizing
constant-time things, I think you have larger problems.)

On Thu, Nov 24, 2016 at 5:48 PM, Victor Stinner <victor.stinner at gmail.com>
wrote:

> Similar or related issue recently open and quickly closed:
> http://bugs.python.org/issue28776
> "Duplicate method names should be an error"
>
> In short, such job should be done by linters. I'm quite sure that many
> of them already implement such check.
>
> Victor
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20161125/df9b3fd6/attachment.html>


More information about the Python-ideas mailing list