Skip to content

Extremely slow type checking of code involving pandas arithmetic #3039

@hamdanal

Description

@hamdanal

This snippet takes 1.14s to check

import pandas as pd

df = pd.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6], "c": [7, 8, 9]})
df["d"] = df["a"] + df["b"] + df["c"] + 1 + (df["a"] ** 2 + df["b"] ** 2 + df["c"] ** 2)

In a project of mine with lots of similar code, ty is almost unusable as a language server.

Note that pandas-stubs has a ton of overloads for binary operator methods (example). That and the fact that mypy has a similar problem where the snippet above takes more than 6s to check make me think that the current situation is the best that ty can do. I am opening this issue anyhow in case ty could do better.

Versions:

ty            0.0.23
numpy         2.4.3
pandas        3.0.1
pandas-stubs  3.0.0.260204

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions