Skip to content
This repository has been archived by the owner. It is now read-only.

Do not create org/python/types/Functions until needed #902

Merged
merged 19 commits into from Aug 31, 2018

Conversation

@patiences
Copy link
Contributor

@patiences patiences commented Aug 9, 2018

Each org/python/types object does a certain amount of initialisation work which currently includes loading (creating) all the functions that are defined on python objects (+, ==, etc). This PR proposes to not create those functions until they are specifically asked for. The resulting performance gain is a modest boost for start-up time and is linear in the number of classes that are referenced/created.

Results on benchmarking test:

Without optimization

Running test_init
  Elapsed time:  0.5658640359979472  sec
  CPU process time:  0.00010599999999993948  sec
Running test_init
  Elapsed time:  0.6104675190035778  sec
  CPU process time:  9.599999999998499e-05  sec
Running test_class_init
  Elapsed time:  0.5521897639991948  sec
  CPU process time:  0.00011099999999997223  sec

With optimization

Running test_class_init
  Elapsed time:  0.32723955099936575  sec
  CPU process time:  7.900000000005125e-05  sec
Running test_class_init
  Elapsed time:  0.38820800599933136  sec
  CPU process time:  0.00010399999999999299  sec
Running test_class_init
  Elapsed time:  0.3487427390027733  sec
  CPU process time:  0.00010099999999990672  sec

About a 30% improvement, but again, this is a one-time benefit.

@patiences patiences changed the title [WIP] Do not create org/python/types/Functions until needed Do not create org/python/types/Functions until needed Aug 13, 2018
Copy link
Member

@freakboy3742 freakboy3742 left a comment

👍

@freakboy3742 freakboy3742 merged commit 05a57e7 into beeware:master Aug 31, 2018
5 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants