Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A milestone for dropping provisional status? #247

Closed
ilevkivskyi opened this issue Jul 14, 2016 · 13 comments
Closed

A milestone for dropping provisional status? #247

ilevkivskyi opened this issue Jul 14, 2016 · 13 comments

Comments

@ilevkivskyi
Copy link
Member

ilevkivskyi commented Jul 14, 2016

PEP 484 will drop its provisional status at some point. I hope this will happen in time for 3.6.
I propose to create a milestone to estimate how much work should be done before this happens.
Here are some issues that I propose to add to this milestone:

Big things:

Smaller things:

I could volunteer to take care about all of the above except #11 (it probably will be better done by Jukka) and SelfType. By "take care" I mean make PRs to PEPs and typing.py. However, I do not exclude also working on some of these in mypy if necessary. I think it is not necessary for mypy to support all the features at the point when PEP 484 drops provisional status, they could be implemented later.

@vlasovskikh
Copy link
Member

And #208, I'm working on it.

@JukkaL
Copy link
Contributor

JukkaL commented Jul 15, 2016

There's no issue for this yes, but I'd want us to resolve the slowness of expressions like List[int], as each of these constructs a new type object (or even multiple type objects if the type is more complex). I did some quick benchmarking a while ago and it seems that type annotations can slow down program startup significantly. Also, it can affect the performance of code with nested, annotated functions and casts to complex types.

This was discussed at PyCon and somebody (@ambv?) raised this as a potential issue.

@ilevkivskyi
Copy link
Member Author

@JukkaL There was a proposal #130 to cache outcomes of such things. The issue is closed now.
I think that this is in fact also related to #136 . For example, Union[str, int] does not need to be a class, anyway one should not subclass it, and it will not support issubclass etc.

I think that making some typing objects more lightweight together with cashing could give a significant speed-up (also @markshannon will be happy).

I think if @gvanrossum does not object (he closed that issue), then you could reopen #130 to track this.

@JukkaL
Copy link
Contributor

JukkaL commented Jul 15, 2016

Caching would likely be quite helpful with casts and nested functions, but it might not eliminate enough of the startup overhead.

I think that we should have some (repeatable) benchmark figures so that we understand the scope of the problem before starting to optimize things. Also, perhaps we should also come up with a target acceptable performance level, such as "don't make program startup more than 10% slower compared to unannotated code for typical (?) programs".

@JukkaL
Copy link
Contributor

JukkaL commented Jul 15, 2016

Another thing we may want to resolve is IO[bytes] vs. BinaryIO (and [IO[str] vs. TextIO). Maybe having IO[AnyStr] would be sufficient?

@gvanrossum
Copy link
Member

gvanrossum commented Jul 15, 2016 via email

@ilevkivskyi
Copy link
Member Author

If some issues from the original list are fixed I will just edit it not to bother everyone.

@gvanrossum
Copy link
Member

gvanrossum commented Aug 24, 2016

FWIW I don't think we should hold our breath for many of these.

@ilevkivskyi
Copy link
Member Author

@gvanrossum I would say that #136 is the most important for me in this list. Protocols, Intersection, and Implementation would be nice to have. Actually, they all three go along the same idea - type checking beyond nominal subtyping (or decoupling types and classes). I particular, Intersection would be more important with protocols (with nominal subtyping C = Intersection(A, B) is practically equivalent to class C(A, B): pass). Also, Implementation allows more fine tuned control of subtyping in contrast to purely nominal type system (where A is a subtype of B iff A is explicitly declared as a subclass of B). Flexible Callable is quite a self contained (but not so big) proposal. Probably, I should agree that these will slow us down. A possible solution would be to consider these two ideas (type checking beyond nominal subtyping and flexible Callable syntax) later after ironing out all the necessary details (maybe as separate PEPs).

Concerning #130, it does not require PEP changes directly, but the solution could change the behavior of issubclas and/or isinstance. My opinion here is that Union, Tuple, Optional should not be classes at all, as well as subscripting them should not create classes (this will give some speed-up). Callable is special in this sense, it should be a class (just an alias for collections.abc.Callable) but Callable[<whatever>] should not be a class. Probably, the only things that should be an actual class is Generic[T].

@gvanrossum
Copy link
Member

Yeah, I think you have the right idea. #136 especially needs to be sorted
out before we can call the PEP finalized, and I agree with you on Union
etc. -- they just need to be simple objects that record the parameters.

Pure additions to typing.py can be their own PEP or even discussed in the
Python bug tracker (though I would much prefer to have them in the tracker
here, regardless of whether they need a PEP, since working with
bugs.python.org is so much more painful).

@gvanrossum
Copy link
Member

So this was never actually decided, however the 3.6 what's new says typing.py is no longer provisional. I actually now believe that's premature. Can we keep it provisional for 3.6?

@gvanrossum
Copy link
Member

I've filed http://bugs.python.org/issue29316 to discuss this.

penguinolog added a commit to python-useful-helpers/advanced-descriptors that referenced this issue May 31, 2018
1. Add links on documentation and bug tracker
2. Install/update typing on python 3.7 too ( python/typing#247 )
@ilevkivskyi
Copy link
Member Author

FWIW typing is no more provisional, so I think this may be closed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants