| commit | e2bb3543bbe728d1affd12efd707954a2fd51a9a | [log] [tgz] |
|---|---|---|
| author | Stiopa Koltsov <stepan.koltsov@gmail.com> | Thu Jul 16 04:47:17 2020 -0700 |
| committer | Copybara-Service <copybara-worker@google.com> | Thu Jul 16 04:48:13 2020 -0700 |
| tree | 226ea5f02b7932df346821178a5af7ba405d96a2 | |
| parent | c940fa47b73df31cf255c8073918446490ce670a [diff] |
Starlark: optimize Dict.plus
`Dict.plus` is used in implementations of `dict` and `dict.update`.
Optimize:
* allocate capacity at construction
* update resulting dict without validation of input dict maps
* iterate underlying maps of input dicts
This test becomes almost two times faster:
```
def test():
d = {x: x for x in range(100)}
for i in range(10):
print(i)
for j in range(100000):
dict(d)
test()
```
```
A: N=9, r=5.129+-0.183
B: N=9, r=3.176+-0.155
B/A: 0.619
```
Closes #11785.
PiperOrigin-RevId: 321542802
{Fast, Correct} - Choose two
Build and test software of any size, quickly and reliably.
Speed up your builds and tests: Bazel rebuilds only what is necessary. With advanced local and distributed caching, optimized dependency analysis and parallel execution, you get fast and incremental builds.
One tool, multiple languages: Build and test Java, C++, Android, iOS, Go, and a wide variety of other language platforms. Bazel runs on Windows, macOS, and Linux.
Scalable: Bazel helps you scale your organization, codebase, and continuous integration solution. It handles codebases of any size, in multiple repositories or a huge monorepo.
Extensible to your needs: Easily add support for new languages and platforms with Bazel's familiar extension language. Share and re-use language rules written by the growing Bazel community.
Follow our tutorials:
See CONTRIBUTING.md