Le mercredi 16 décembre 2015, Franklin? Lee <leewangzhong+pyt...@gmail.com> a écrit : > > I am confident that the time overhead and the savings will beat the > versioning dict. The versioning dict method has to save a reference to > the variable value and a reference to the name, and regularly test > whether the dict has changed.
The performance of guards matters less than the performance of regular usage of dict. If we have to make a choice, I prefer "slow" guard but no impact on regular dict methods. It's very important that enabling FAT mode doesn't kill performances. Remember that FAT python is a static optimizer and so can only optimize some patterns, not all Python code. In my current implementation, a lookup is only needed when aguard is checked if the dict was modified. The dict version doesn't change if a mutable object was modified in place for example. I didn't benchmark, but I expect that the lookup is avoided in most cases. You should try FAT python and implement statistics before going too far in your idea. > I've read it again. By subclass, I mean that it implements the same > interface. But at the C level, I want to have it be a fork(?) of the > current dict implementation. As for `exec`, I think it might be okay > for it to be slower at the early stages of this game. Be careful, dict methods are hardcoded in the C code. If your type is not a subtype, there is risk of crashes. I fixed issues in Python/ceval.c, but it's not enough. You may also have to fix issues in third party C extensions why only expect dict for namespaces. Victor
_______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com