[Python-Dev] Experiences with Creating PEP 484 Stub Files (original) (raw)
Andrew Barnert abarnert at yahoo.com
Tue Feb 9 12:58:17 EST 2016
- Previous message (by thread): [Python-Dev] Experiences with Creating PEP 484 Stub Files
- Next message (by thread): [Python-Dev] Experiences with Creating PEP 484 Stub Files
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Feb 9, 2016, at 03:44, Phil Thompson <phil at riverbankcomputing.com> wrote:
There are a number of things I'd like to express but cannot find a way to do so... - objects that implement the buffer protocol
That seems like it should be filed as a bug with the typing repo. Presumably this is just an empty type that registers bytes, bytearray, and memoryview, and third-party classes have to register with it manually?
- type objects - slice objects
Can't you just use the concrete types type and slice tor these two? I don't think you need generic or abstract "any metaclass, whether inheriting from type or not" or "any class that meets the slice protocol", do you?
- capsules
That one seems reasonable. But maybe there should just be a types.Capsule Type or types.PyCapsule, and then you can just check that the same as any other concrete type?
But how often do you need to verify that something is a capsule, without knowing that it's the right capsule? At runtime, you'd usually use PyCapsule_IsValid, not PyCapsule_CheckExacf, right? So should the type checker be tracking the name too?
- sequences of fixed size (ie. specified in the same way as Tuple)
How would you disambiguate between a sequence of one int and a sequence of 0 or more ints if they're both spelled "Sequence[int]"? That isn't a problem for Tuple, because it's assumed to be heterogeneous, so Tuple[int] can only be a 1-tuple. (This was actually discussed in some depth. I thought it would be a problem, because some types--including tuple itself--are sometimes used as homogenous arbitrary-length containers and sometimes as heterogeneous fixed-length containers, but Guido and others had some good answers for that, even if I can't remember what they were.)
- distinguishing between instance and class attributes.
Where? Are you building a protocol that checks the data members of a type for conformance or something? If so, why is an object that has "spam" and "eggs" as instance attributes but "cheese" as a class attribute not usable as an object conforming to the protocol with all three attributes? (Also, does @property count as a class or instance attribute? What about an arbitrary data descriptor? Or a non-data descriptor?)
- Previous message (by thread): [Python-Dev] Experiences with Creating PEP 484 Stub Files
- Next message (by thread): [Python-Dev] Experiences with Creating PEP 484 Stub Files
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]