Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Don't mess with builtin #1

Open
Suor opened this Issue · 4 comments

2 participants

@Suor

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.

@rfk
Owner
rfk commented

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

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.

@rfk
Owner
rfk commented

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
Something went wrong with that request. Please try again.