🌐 AI搜索 & 代理 主页
Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: python/mypy
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master@{1day}
Choose a base ref
...
head repository: python/mypy
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 4 commits
  • 12 files changed
  • 4 contributors

Commits on Dec 11, 2025

  1. [mypyc] Fix calling async methods through vectorcall (#20393)

    Fixes mypyc/mypyc#1170
    
    Fixed a bug introduced when adding the async function wrapper in
    81eaa5d
    that would result in `TypeErrors` being raised when the wrapped function
    was called using the vectorcall protocol.
    
    The exception was caused by the wrapper keeping the `self` argument of
    methods in the `args` vector instead of extracting it to a separate c
    function argument. The called function would not expect the `self`
    argument to be part of `args` so it appeared as if too many arguments
    were passed.
    p-sawicki authored Dec 11, 2025
    Configuration menu
    Copy the full SHA
    6adb7a4 View commit details
    Browse the repository at this point in the history
  2. [mypyc] Add primitive for bytes.startswith (#20387)

    Implements `bytes.startswith` in mypy. Potentially could be more
    efficient without relying on `memcmp` but not sure.
    
    Tested with the following benchmark code, which shows a ~6.3x
    performance improvement compared to standard Python:
    
    ```
    import time
    
    def bench(prefix: bytes, a: list[bytes], n: int) -> int:
        i = 0
        for x in range(n):
            for b in a:
                if b.startswith(prefix):
                    i += 1
        return i
    
    
    a = [b"foo", b"barasdfsf", b"foobar", b"ab", b"asrtert", b"sertyeryt"]
    n = 5 * 1000 * 1000
    prefix = b"foo"
    
    bench(prefix, a, n)
    
    t0 = time.time()
    bench(prefix, a, n)
    td = time.time() - t0
    print(f"{td}s")
    ```
    
    Output:
    ```
    $ python /tmp/bench.py
    1.0015509128570557s
    $ python -c 'import bench'
    0.154998779296875s
    ```
    esarp authored Dec 11, 2025
    Configuration menu
    Copy the full SHA
    1cea058 View commit details
    Browse the repository at this point in the history
  3. [mypyc] feat: use get_expr_length_value in translate_len (#20074)

    Currently, `translate_len` can determine the length of an RTuple at
    compile time
    
    This PR extends this capability to all expressions supported by
    `get_expr_length_value`
    
    This will constant fold the code example displayed in
    mypyc/mypyc#1152 without waiting for the
    implementation of #19886 which has a few steps ahead of it
    
    Before:
    ```python
    def extend_and_specialize(items: list[dict[str, Any]]) -> None:
        types: Final[dict[str, Any]] = {i["name"]: i for i in items}
        types.update(
            {
                k[len("https://w3id.org/cwl/salad#") :]: v
                for k, v in types.items()
                if k.startswith("https://w3id.org/cwl/salad#")
            }
        )
    ```
    
    After:
    ```python
    def extend_and_specialize(items: list[dict[str, Any]]) -> None:
        types: Final[dict[str, Any]] = {i["name"]: i for i in items}
        types.update(
            {
                k[27 : ]: v
                for k, v in types.items()
                if k.startswith("https://w3id.org/cwl/salad#")
            }
        )
    ```
    
    Even after #19986, this will also work for some situations that constant
    folding cannot handle but `get_expr_length` can.
    BobTheBuidler authored Dec 11, 2025
    Configuration menu
    Copy the full SHA
    34373e3 View commit details
    Browse the repository at this point in the history
  4. Fix Typo attr -> attrs (#20400)

    In the example, `attrs` is used, even though `attr` is imported.
    Picking either one isn't important, but the code gives a runtime error
    when the other one is used.
    George-Ogden authored Dec 11, 2025
    Configuration menu
    Copy the full SHA
    12d53f6 View commit details
    Browse the repository at this point in the history
Loading