| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
Oh, hm, this uncovers an inconsistency in how we format constructors, depending on whether they are decorated or not. IMO def [T] list(self) -> list[T]looks better than def [T] __init__(self) -> list[T]I will see how many tests needs updating to converge on this option, and if not too many, I am going to do it in this PR. |
Sorry, something went wrong.
|
Yeah, no, 15 tests need to be updated, this will also probably cause some noisy mypy_primer, so better to do in a separate PR. (Also maybe others have a different idea on which way looks better) |
Sorry, something went wrong.
|
Diff from mypy_primer, showing the effect of this PR on open source code: pydantic (https://github.com/pydantic/pydantic)
- pydantic/v1/validators.py:615: note: def NamedTuple(self, str, Iterable[tuple[str, Any]], /) -> NamedTupleT
+ pydantic/v1/validators.py:615: note: def __init__(self, str, Iterable[tuple[str, Any]], /) -> NamedTupleT
- pydantic/v1/validators.py:615: note: def NamedTuple(self, str, None = ..., /, **kwargs: Any) -> NamedTupleT
+ pydantic/v1/validators.py:615: note: def __init__(self, str, None = ..., /, **kwargs: Any) -> NamedTupleT
|
Sorry, something went wrong.
There was a problem hiding this comment.
LG, thanks! I personally prefer def __init__(...) by a huge margin - def ClassName(...) looks confusing, trying to untangle the latter always takes me a few extra seconds.
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
This is mypyc-specific optimization: dict creation is quite slow, so we should not create a dict in the CallableType constructor. Instead, I store the required info on the relevant FuncDef object (and restore the link to definition in fixup.py). Quite surprisingly, this gives 2% speedup on my desktop.