Don't mess with builtin #1

Open
Suor opened this Issue Nov 1, 2012 · 4 comments

Projects

None yet

2 participants

@Suor
Suor commented Nov 1, 2012

Wouldn't it be cleaner to just provide magic super as drop-in replacement instead of taking it into builtins? Then you just do

from magicsuper import super
# or even
from magicsuper import super as superm

in your module and don't interfere with any 3rd party modules.

Owner
rfk commented Nov 2, 2012

True, although it shouldn't break anything in third-party modules since it eventually just proxies through to the original super() function.

I would strongly encourage you not to use this module for anything serious - apart from being a total hack, the runtime overhead will be substantial compared to the normal use of super() with arguments.

Suor commented Nov 2, 2012

Performance considerations should be negligible when methods do some non-trivial work. And this module could be used to write forward compatible code. Of course, magicsuper should reexport buitin under python 3.

Owner
rfk commented Nov 2, 2012

Hmm...interesting. I had honestly not considered using it in something like six, it was just done as fun hack.

The performance overhead could be mostly mitigated with some caching, e.g. creating a class attribute/cellvar the first time a function is executed, then using that cached value in subsequent calls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment