Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Starlark: @StarlarkMethod.trustReturnsValid #13012

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Commits on May 2, 2022

  1. Starlark: @StarlarkMethod.trustReturnsValid

    When this parameter is specified for method, Starlark interpreter
    assumes function returns a valid Starlark value.
    
    When method is declared to return `Object`, Starlark interpreter
    by default checks that object is a valid Starlark value, which is
    quite expensive.
    stepancheg committed May 2, 2022
    Configuration menu
    Copy the full SHA
    898fbde View commit details
    Browse the repository at this point in the history
  2. Starlark: annotate builtin functions with trustReturnsValid

    Speed up is 4% for this test:
    
    ```
    def test():
      for i in range(10):
        print(i)
        d = {"a": range(10), "b": {}, "c": 4, "d": 5, "e": (), "f": True, "g": []}
        for _ in range(1000000):
          d.get("a")
          d.get("b")
          d.get("c")
          d.get("d")
          d.get("e")
          d.get("f")
          d.get("g")
    
    test()
    ```
    stepancheg committed May 2, 2022
    Configuration menu
    Copy the full SHA
    fcdd290 View commit details
    Browse the repository at this point in the history