[Python-Dev] Third milestone of FAT Python

Victor Stinner victor.stinner at gmail.com
Tue Dec 15 15:29:57 EST 2015


2015-12-15 12:23 GMT+01:00 Franklin? Lee <leewangzhong+python at gmail.com>:
> I was thinking (as an alternative to versioning dicts) about a
> dictionary which would be able to return name/value pairs, which would
> also be internally used by the dictionary. This would be way less
> sensitive to irrelevant changes in the scope dictionary, but cost an
> extra pointer to each key.

Do you have an estimation of the cost of the "extra pointer"? Impact
on memory and CPU. dict is really a very important type for the
performance of Python. If you make dict slower, I'm sure that Python
overall will be slower.

>     del scope[name]
>     assert pair.key is None

It looks tricky to keep the dict and the pair objects consistent,
especially in term of atomaticity. You will need to keep a reference
to the pair object in the dict entry, which will also make the dict
larger (use more memory), right?

> You won't have to keep looking up keys (unless the name is deleted), and
> functions are allowed to change. For inlining, you can detect whether
> the function has been redefined by testing the saved pair.value
> against the saved function, and go into the slow path if needed (or
> recompile the inlining).

For builtin functions, I also need to detect when a key is created in
the global namespace. How do you handle this case with pairs?

> If memory is a real concern, deleted pairs can be weakrefed (and saved
> in a second dict?) until they are reused. This way, pairs which aren't
> saved by something outside will be removed.

Supporting weak references also has a cost on the memory footprint...

For FAT Python, not being able to detect quickly when a new key is
created is a blocker point.

Victor


More information about the Python-Dev mailing list