Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Mypy stuck with polynomial using NumPy #14978

Copy link
Copy link
Open
@not522

Description

@not522
Issue body actions

Bug Report

The original bug report is optuna/optuna#4404.
I tried to make a minimal reproducible example and found that checking the following code with the latest mypy takes about 1 minute.

To Reproduce

import numpy as np
from typing import Any

x: np.ndarray[Any, np.dtype[np.floating]] = np.asarray([1, 2, 3])
1 + x * (1 + x * (1 / 2 + x * (1 / 6 + x * (1 / 24 + x / 120))))

Adding terms as follows seems to increase execution time exponentially.

1 + x * (1 + x * (1 / 2 + x * (1 / 6 + x * (1 / 24 + x * (1 / 120 + x / 720)))))

Expected Behavior

The execution takes a few seconds.

Actual Behavior

$ time mypy exp.py 
Success: no issues found in 1 source file

real	1m17.655s
user	0m55.657s
sys	0m0.892s

Your Environment

  • Mypy version used: 1.1.1
  • Mypy command-line flags: No flags
  • Mypy configuration options from mypy.ini (and other config files): No configs
  • Python version used: 3.9.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.