Commit 793f7d0
Port mock performance improvements
Summary:
It looks like updating to Mock 3.8 has caused some perf regressions. There's some known issues called out here:https://bugs.python.org/issue38895 - this:
* Don't use `inspect` to get `spec` and `spec_sec` - instead now we fully spell out the signature and use the args directly.
* provides a variation on not reflecting over all async methods on creation. The `_spec_asyncs` list still exists, but it is just not populated by default. Instead we'll consult it or check if the function is async.
* Don't create the mock code object on instantiation of the `AsyncMock` - this is actually a huge portion of the cost of creating `AsyncMock` objects.
* Avoid quadruple `self._mock_set_magics()` calls. This is actually done in the `MagicMixin` class so there's no need to do it in the `AsyncMagicMixin`
Reviewed By: carljm
Differential Revision: D35118477
fbshipit-source-id: 38779e01 parent 3342e16 commit 793f7d0
1 file changed
Lines changed: 14 additions & 22 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
398 | 398 | | |
399 | 399 | | |
400 | 400 | | |
401 | | - | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
402 | 404 | | |
403 | 405 | | |
404 | 406 | | |
405 | 407 | | |
406 | 408 | | |
407 | 409 | | |
408 | | - | |
409 | | - | |
410 | | - | |
411 | | - | |
412 | | - | |
413 | | - | |
414 | | - | |
| 410 | + | |
| 411 | + | |
415 | 412 | | |
416 | | - | |
| 413 | + | |
417 | 414 | | |
418 | 415 | | |
419 | 416 | | |
| |||
495 | 492 | | |
496 | 493 | | |
497 | 494 | | |
498 | | - | |
499 | | - | |
500 | | - | |
501 | | - | |
502 | 495 | | |
503 | 496 | | |
504 | 497 | | |
| |||
995 | 988 | | |
996 | 989 | | |
997 | 990 | | |
998 | | - | |
| 991 | + | |
| 992 | + | |
999 | 993 | | |
1000 | 994 | | |
1001 | 995 | | |
| |||
1038 | 1032 | | |
1039 | 1033 | | |
1040 | 1034 | | |
1041 | | - | |
1042 | 1035 | | |
1043 | 1036 | | |
1044 | 1037 | | |
| |||
2044 | 2037 | | |
2045 | 2038 | | |
2046 | 2039 | | |
2047 | | - | |
2048 | | - | |
2049 | | - | |
2050 | | - | |
| 2040 | + | |
2051 | 2041 | | |
2052 | 2042 | | |
2053 | 2043 | | |
| |||
2106 | 2096 | | |
2107 | 2097 | | |
2108 | 2098 | | |
2109 | | - | |
2110 | | - | |
2111 | | - | |
| 2099 | + | |
2112 | 2100 | | |
2113 | 2101 | | |
2114 | 2102 | | |
| |||
2727 | 2715 | | |
2728 | 2716 | | |
2729 | 2717 | | |
| 2718 | + | |
| 2719 | + | |
| 2720 | + | |
| 2721 | + | |
2730 | 2722 | | |
2731 | 2723 | | |
2732 | 2724 | | |
| |||
0 commit comments