Last active
November 5, 2015 17:28
-
-
Save Daetalus/09441b1d5c2c13c6ded8 to your computer and use it in GitHub Desktop.
How to get cls information from class method?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# dict.fromkeys(...) could not set the class information for subclass correctly. | |
# so I want to correct it. | |
# Original code is here: | |
# auto* fromkeys_func | |
# = new BoxedFunction(FunctionMetadata::create((void*)dictFromkeys, DICT, 3, false, false), { None }); | |
# dict_cls->giveAttr("fromkeys", boxInstanceMethod(dict_cls, fromkeys_func, dict_cls)); | |
# I think we should not hardcode the cls information here. And also I want to change it to BoxedBuiltinFunctionOrMethod. | |
# But I don't know how to get the class information if use `fromkeys` like a class method, for example: | |
class dictlike(dict): | |
pass | |
a = dictlike() | |
b = a.fromkeys("b") | |
# in Pyston, get the cls information by | |
# Box* dictFromKeys(Box* self, ...) { | |
# BoxedClass* cls = self->cls; | |
a = dictlike.fromkeys("a") | |
# how to get the cls information in this situation in Pyston? | |
# Neither `cls = self->cls;` nor `cls = static_cast<BoxedClass*>self` will work. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment