Message274938
| Author |
levkivskyi |
| Recipients |
gvanrossum, levkivskyi |
| Date |
2016年09月08日.00:59:46 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1473296387.16.0.0224669848227.issue27985@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
Guido,
I fixed __annotations__ in interactive REPL, will fix other minor things and submit a new patch tomorrow morning.
There are two important questions in typing.py:
> Why is the second isinstance() needed? Isn't _ClassVar a subclass of
> TypingMeta
and
> This being a metaclass, the name should end in Meta, like most
> other subclasses of TypingMeta. (And they don't have a leading _,
> though they're still not public.)
The problem with ClassVar is that it is not actually a class, and _ClassVar is not a metaclass, it is just a class. I deviated from the common pattern in module for the following reason. ClassVar is going to be extensively used at class scope, where all annotations are evaluated. Therefore I wanted not to create new class objects by __getitem__ like it is going for other classes like Union etc (I tried to timeit this and ClassVar is almost ten times faster than Union)
What do you think?
Should I keep it like this, or rewrite in a common pattern for the module? |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2016年09月08日 00:59:47 | levkivskyi | set | recipients:
+ levkivskyi, gvanrossum |
| 2016年09月08日 00:59:47 | levkivskyi | set | messageid: <1473296387.16.0.0224669848227.issue27985@psf.upfronthosting.co.za> |
| 2016年09月08日 00:59:47 | levkivskyi | link | issue27985 messages |
| 2016年09月08日 00:59:46 | levkivskyi | create |
|