Le mercredi 16 décembre 2015, Franklin? Lee <<a href="mailto:leewangzhong%2Bpython@gmail.com">leewangzhong+python@gmail.com</a>> a écrit :<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I am confident that the time overhead and the savings will beat the<br>
versioning dict. The versioning dict method has to save a reference to<br>
the variable value and a reference to the name, and regularly test<br>
whether the dict has changed.</blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"></blockquote><div><br></div>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.<div><br></div><div>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.<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I've read it again. By subclass, I mean that it implements the same<br>
interface. But at the C level, I want to have it be a fork(?) of the<br>
current dict implementation. As for `exec`, I think it might be okay<br>
for it to be slower at the early stages of this game.</blockquote><div><br></div><div>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.</div></div><div><br></div><div>Victor</div>