Skip to content

Optimize dict string keys #734

Description

@dg-pb
./python.exe -m timeit -s 'd = {"a": 1}' 'd["a"]'
# 10000000 loops, best of 5: 29.1 nsec per loop
S="
class A: pass
d = A()
d.a = 1
"
./python.exe -m timeit -s $S 'd.a'
# 20000000 loops, best of 5: 17.3 nsec per loop

I think string-only-key dict is very common.
If there is optimisation technique done for attribute access, how difficult it would be to transfer similar benefit to dict object?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions