ruff
36b92bb2 - [ty] Check protocol member names before specializing the source interface (#30445)

Commit
3 days ago
[ty] Check protocol member names before specializing the source interface (#30445) ## Summary When comparing generic protocols, ty specializes the source’s members before discovering that a required member is missing. We now check the first required name that `object` doesn’t provide. If the source and its base classes lack that name, we can reject the comparison immediately. The larger NumPy check saved 0.15% of instructions. A successful 49-member protocol stress case used 0.36% more. | Project | [Base instructions](https://github.com/astral-sh/ruff/commit/6bf61927fd328ff83b36ea6484a86dfedc53c340) | [PR instructions](https://github.com/astral-sh/ruff/commit/dda61822347385a7a4e4d3d1cb0634079a0ed9d6) | Change | Paired range | | :--- | ---: | ---: | ---: | :--- | | [Black](https://github.com/psf/black/tree/55996d1fb8342725c8a19b6023cd9439c3c1d6f7) | 3,189,153,694 | 3,195,522,185 | +0.20% | +0.13% to +0.27% | | [discord.py](https://github.com/Rapptz/discord.py/tree/65232c38702be5844cf2ce865a4777eb1928b5d0) | 8,271,324,202.5 | 8,287,035,400 | +0.19% | +0.15% to +0.23% | | [Django](https://github.com/django/django/tree/b501b8493f31cf8cba31211d59b3b78642b8cb02) | 14,008,171,426 | 14,029,005,636.5 | +0.15% | +0.10% to +0.20% | | [FastAPI](https://github.com/fastapi/fastapi/tree/7a0a3f0b286c6c865cf4398ea0e957a87b8bffa4) | 3,018,892,189 | 3,027,247,422 | +0.31% | -0.35% to +0.52% | | [Home Assistant](https://github.com/home-assistant/core/tree/c19ae285ede74cd64c3045a3a4aa43290c224f1b) | 160,164,140,559.5 | 160,055,392,562.5 | -0.07% | -0.09% to -0.05% | | [HTTPX](https://github.com/encode/httpx/tree/b5addb64f0161ff6bfe94c124ef76f6a1fba5254) | 1,675,421,289 | 1,672,311,473 | -0.18% | -0.58% to +0.21% | | [isort](https://github.com/pycqa/isort/tree/a514c71ed86c2216d0040c7d60e302ed76a4f7ab) | 1,841,755,068 | 1,842,190,245 | +0.02% | +0.01% to +0.04% | | [Jinja](https://github.com/pallets/jinja/tree/5ef70112a1ff19c05324ff889dd30405b1002044) | 1,935,895,714 | 1,927,851,995 | -0.42% | -0.58% to -0.25% | | [NumPy](https://github.com/numpy/numpy/tree/f9f1772ce010001208475f751d19253469788410) | 9,016,906,198.5 | 8,616,683,232 | -4.44% | -4.87% to -4.00% | | [OpenAI Python SDK](https://github.com/openai/openai-python/tree/f6e8480f9a5b2a4d02b17a1da54a1e57964bc312) | 15,995,025,094.5 | 15,965,301,708.5 | -0.19% | -0.19% to -0.18% | | [pandas](https://github.com/pandas-dev/pandas/tree/a0225b65720018f4654390bb16d254daa6ee5e54) | 30,305,048,327 | 30,134,727,537 | -0.56% | -0.65% to -0.47% | | [pandas-stubs](https://github.com/pandas-dev/pandas-stubs/tree/8dd6d91b1c05b26e30f7ddbe3dc3d4042a92bdd6) | 2,940,012,272.5 | 2,934,812,358 | -0.18% | -0.24% to -0.11% | | [Prefect](https://github.com/PrefectHQ/prefect/tree/a9452ac21852755311913cb27887b083b5007c03) | 4,906,149,744.5 | 4,906,045,674 | 0.00% | -0.05% to +0.04% | | [pytest](https://github.com/pytest-dev/pytest/tree/8b005ed7f972987033ec34dc1e68b0635fb8142b) | 8,845,062,801.5 | 8,838,006,594.5 | -0.08% | -0.08% to -0.08% | | [PyTorch](https://github.com/pytorch/pytorch/tree/ab92945cea42e47ae398aead69af0872d340ea0f) | 98,275,445,653.5 | 98,164,087,812 | -0.11% | -0.12% to -0.11% | | [Rich](https://github.com/Textualize/rich/tree/9d8f9a372cc5916fd4781fec207ced7ddac2f08f) | 2,712,880,137.5 | 2,709,082,810.5 | -0.14% | -0.50% to +0.22% | | [SQLAlchemy](https://github.com/sqlalchemy/sqlalchemy/tree/10f4d1e2d706a7722ca78e79ce05b00333a7aa5b) | 21,843,482,137.5 | 21,869,645,614.5 | +0.12% | +0.11% to +0.13% | | [SymPy](https://github.com/sympy/sympy/tree/85d3998a4517ffbc8a9709b8efa769bb417c174a) | 46,763,163,715.5 | 46,736,979,809 | -0.06% | -0.07% to -0.04% | | [aiohttp](https://github.com/aio-libs/aiohttp/tree/fe099491d275ef2c21bf683e024e34d51ac05d43) | 4,155,722,484.5 | 4,161,983,049 | +0.15% | +0.13% to +0.17% | | [Ansible](https://github.com/ansible/ansible/tree/b4b2b1e82a535d27f902a71fc8396c3af138fca2) | 14,596,829,668 | 14,600,743,257.5 | +0.03% | +0.02% to +0.03% | | [botocore](https://github.com/boto/botocore/tree/e250abbe956da791c16086575e6ddb1f2da81a78) | 3,001,284,986.5 | 3,000,941,623.5 | -0.01% | -0.07% to +0.05% | | [Celery](https://github.com/celery/celery/tree/9c2f238334331db43f15956f131235fd3bb70fd1) | 4,826,870,671 | 4,831,000,527.5 | +0.09% | +0.03% to +0.14% | | [Dask](https://github.com/dask/dask/tree/249a51a1db4261791b93b4ce04e67341729939c3) | 36,475,564,934.5 | 36,148,279,180 | -0.90% | -0.92% to -0.88% | | [NetworkX](https://github.com/networkx/networkx/tree/6855cd586982cc2e4710b8eb87251ccf56674bf1) | 16,659,677,357 | 16,513,941,898.5 | -0.87% | -0.95% to -0.80% | | [Pydantic](https://github.com/pydantic/pydantic/tree/560f0f96a37d6913afdfddb2de22030ef08e68c3) | 15,923,299,274 | 15,905,062,087.5 | -0.11% | -0.17% to -0.06% | | [scikit-learn](https://github.com/scikit-learn/scikit-learn/tree/ee56c8b5d809dc7b970a140ed501269b63c69cf8) | 77,921,923,652 | 76,916,522,116.5 | -1.29% | -1.37% to -1.21% | | [Scrapy](https://github.com/scrapy/scrapy/tree/e63a574c767d7a9438c21db158f605f1c44c6e6a) | 8,950,615,809.5 | 8,952,371,055.5 | +0.02% | -0.04% to +0.08% | | [Transformers](https://github.com/huggingface/transformers/tree/3a134bc37f7c22c801b618e289b0255425f22647) | 105,278,037,248 | 105,048,269,879 | -0.22% | -0.23% to -0.20% |
Author
Parents
Loading