[issue42195] Inconsistent __args__ between typing.Callable and collections.abc.Callable

2020-10-31 Thread Ken Jin
Ken Jin added the comment: Hi, I submitted a PR for a proof-of-concept on how the code which subclasses GenericAlias might look like for everyone's consideration. Personally, I'd lean more towards what Serhiy said and change typing.Callable rather than GenericAlias which af

[issue42198] Clean up docs for Union and GenericAlias

2020-10-31 Thread Ken Jin
Change by Ken Jin : -- pull_requests: +21980 pull_request: https://github.com/python/cpython/pull/23061 ___ Python tracker <https://bugs.python.org/issue42

[issue42198] Clean up docs for Union and GenericAlias

2020-10-31 Thread Ken Jin
Ken Jin added the comment: Guido, I have one last one -- "2. Park GenericAlias and Union under a new section 'Type Annotation Types' in stdtypes for 3.10". After which I'll close this issue. Thanks for reviewing my PRs so quickly! -- _

[issue42198] Clean up docs for Union and GenericAlias

2020-10-31 Thread Ken Jin
Change by Ken Jin : -- pull_requests: +21982 pull_request: https://github.com/python/cpython/pull/23063 ___ Python tracker <https://bugs.python.org/issue42

[issue40814] Update typing module documentation based on PEP 585

2020-10-31 Thread Ken Jin
Ken Jin added the comment: IMO, this can now be closed. Most code examples in typing were changed to builtin generics: https://github.com/python/cpython/commit/d9ab95ff1fe81efdf70e545d536d9f6927d1ba81 https://github.com/python/cpython/commit/7f54e563dc150cd670ca8df678437455c3a7f2cd Docs for

[issue42233] GenericAlias does not support union type expressions

2020-11-01 Thread Ken Jin
New submission from Ken Jin : Union type expressions added in PEP 604 throw an error when both operands are GenericAlias objects. Eg the following works:: int | list[str] The following throws TypeError:: list[int] | dict[float, str] Traceback (most recent call last): File "",

[issue42233] GenericAlias does not support union type expressions

2020-11-01 Thread Ken Jin
Change by Ken Jin : -- keywords: +patch pull_requests: +21997 stage: -> patch review pull_request: https://github.com/python/cpython/pull/23077 ___ Python tracker <https://bugs.python.org/issu

[issue42233] GenericAlias does not support union type expressions

2020-11-01 Thread Ken Jin
Ken Jin added the comment: @Serhiy, wow interesting find, it seems to be typing's repr problem rather than the actual types itself: >>> typing.Union[dict[int, str], list[str]] typing.Union[dict, list] >>> typing.Union[dict[int, str], list[str]].__args__ (dict[int

[issue42233] GenericAlias does not support union type expressions

2020-11-01 Thread Ken Jin
Change by Ken Jin : -- pull_requests: +21999 pull_request: https://github.com/python/cpython/pull/23081 ___ Python tracker <https://bugs.python.org/issue42

[issue42195] Inconsistent __args__ between typing.Callable and collections.abc.Callable

2020-11-01 Thread Ken Jin
Ken Jin added the comment: Dear Guido, from what I can see in the typing module, _CallableType already casts the args list to a tuple before creating the __CallableGenericAlias, so it should support cacheing. This is taken from the from _CallableType:: def __getitem__(self, params

[issue42245] concurrent.futures.ProcessPoolExecutor freezes depending on complexity

2020-11-02 Thread Ken Jin
Ken Jin added the comment: Hello, it would be great if you can you provide more details. Like your Operating System and version, how many logical CPU cores there are on your machine, and lastly the exact Python version with major and minor versions included (eg. Python 3.8.2

[issue42245] concurrent.futures.ProcessPoolExecutor freezes depending on complexity

2020-11-02 Thread Ken Jin
Ken Jin added the comment: Hmm apologies I'm stumped then. The only things I managed to surmise from xgboost's and scikit-learn's GitHub issues is that this is a recurring issue specifically when using GridSearchCV : Threads with discussions on workarounds: https://github.c

[issue40816] Add missed AsyncContextDecorator to contextlib

2020-11-05 Thread Ken Jin
Change by Ken Jin : -- nosy: +kj nosy_count: 5.0 -> 6.0 pull_requests: +22076 pull_request: https://github.com/python/cpython/pull/23164 ___ Python tracker <https://bugs.python.org/issu

[issue20774] collections.deque should ship with a stdlib json serializer

2020-11-05 Thread Ken Jin
Ken Jin added the comment: Sorry to butt into this conversation, but I wanted to add that I have interest in this feature - deques are the fourth most common container types I use in Python. Is there any way I can help to get this PR across the finish line? So far I've forked t

[issue42280] The list of standard generic collections is incomplete

2020-11-07 Thread Ken Jin
Ken Jin added the comment: Dear Jack, good catch! My only worry is that if we make the list exhaustive, it would be too lengthy, or that it might not be feasible to continuously update it every time a new generic type supports the feature. Maybe a line somewhere to mention that most

[issue42233] GenericAlias does not support union type expressions

2020-11-08 Thread Ken Jin
Change by Ken Jin : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker <https://bugs.python.or

[issue42294] [C API] Add new C functions with more regular reference counting like PyTuple_GetItemRef()

2020-11-10 Thread Ken Jin
Change by Ken Jin : -- nosy: +kj nosy_count: 5.0 -> 6.0 pull_requests: +22130 pull_request: https://github.com/python/cpython/pull/23227 ___ Python tracker <https://bugs.python.org/issu

[issue42317] Docs of `typing.get_args`: Mention that due to caching of typing generics the order of arguments for Unions can be different from the one of the returned tuple

2020-11-11 Thread Ken Jin
Ken Jin added the comment: You're right, currently this happens for 2 reasons: 1. _SpecialGenericAlias (used by List), caches its __getitem__. (As you already pointed out :) ) 2. _UnionGenericAlias (Union)'s __hash__ is `hash(frozenset(self.__args__))`. i.e. Unions with diff

[issue42245] concurrent.futures.ProcessPoolExecutor freezes depending on complexity

2020-11-11 Thread Ken Jin
Ken Jin added the comment: Danil, thanks for finding the cause behind this. Could you check if the new behavior in Python 3.8 and higher has the same problem on your machine (without your fix)? multiprocessing on MacOS started using spawn in 3.8, and I was wondering if it that fixed it

[issue42332] add __weakref__ to types.GenericAlias

2020-11-12 Thread Ken Jin
Change by Ken Jin : -- keywords: +patch nosy: +kj nosy_count: 2.0 -> 3.0 pull_requests: +22147 stage: -> patch review pull_request: https://github.com/python/cpython/pull/23250 ___ Python tracker <https://bugs.python.org/i

[issue42317] Docs of `typing.get_args`: Mention that due to caching of typing generics the order of arguments for Unions can be different from the one of the returned tuple

2020-11-12 Thread Ken Jin
Ken Jin added the comment: Dominik, would you like to submit a PR for this :) ? -- ___ Python tracker <https://bugs.python.org/issue42317> ___ ___ Python-bug

[issue42354] Tuple unpacking with * causes SyntaxError in with ... as ...

2020-11-14 Thread Ken Jin
Ken Jin added the comment: This is a duplicate of issue bpo-41979, which was already fixed in this merged PR https://github.com/python/cpython/pull/22611 and backported to 3.9. The example code does not error on the latest 3.10. I'm guessing that the bugfix will come in 3.9.1 since th

[issue42345] Equality of typing.Literal depends on the order of arguments

2020-11-15 Thread Ken Jin
Ken Jin added the comment: @Guido and @Ivan, Should Literals de-duplicate values in its __args__ similar to Union? PEP 586 states that: > Literal[v1, v2, v3] is equivalent to Union[Literal[v1], Literal[v2], > Literal[v3]] Naturally, a Union de-duplicates values, so I was wonder

[issue42332] add __weakref__ to types.GenericAlias

2020-11-15 Thread Ken Jin
Change by Ken Jin : -- pull_requests: +22200 pull_request: https://github.com/python/cpython/pull/23309 ___ Python tracker <https://bugs.python.org/issue42

[issue42345] Equality of typing.Literal depends on the order of arguments

2020-11-18 Thread Ken Jin
Change by Ken Jin : -- pull_requests: +22278 pull_request: https://github.com/python/cpython/pull/23385 ___ Python tracker <https://bugs.python.org/issue42

[issue42345] Equality of typing.Literal depends on the order of arguments

2020-11-18 Thread Ken Jin
Change by Ken Jin : -- pull_requests: +22279 pull_request: https://github.com/python/cpython/pull/23386 ___ Python tracker <https://bugs.python.org/issue42

[issue42195] Inconsistent __args__ between typing.Callable and collections.abc.Callable

2020-11-19 Thread Ken Jin
Ken Jin added the comment: I tried to implement Callable[[int, int], str] as ((int, int), str). However, it breaks much of typing's tests and requires recursion to account for the nested tuples, in both typing, and in the C implementation of GenericAlias. I'd like to humbly prop

[issue42195] Inconsistent __args__ between typing.Callable and collections.abc.Callable

2020-11-22 Thread Ken Jin
Ken Jin added the comment: @guido, Aesthetics-wise, I agree that ((int, int), str) looks by far the best. My gripe with it lies with the implementation - almost every function in typing currently assumes that every object in __args__ is a type, having (int, int) - the tuple object

[issue42195] Inconsistent __args__ between typing.Callable and collections.abc.Callable

2020-11-22 Thread Ken Jin
Ken Jin added the comment: A possible workaround for _PosArgs in collections.abc without depending on typing could be like this: _PosArgs = type('_PosArgs', (tuple, ), {}) This would help out the future type proposals too, because GenericAlias accepts non-type args. __args__ o

[issue8264] [doc] hasattr doesn't show private (double underscore) attributes exist

2020-11-25 Thread Ken Jin
Change by Ken Jin : -- nosy: +kj nosy_count: 4.0 -> 5.0 pull_requests: +22400 pull_request: https://github.com/python/cpython/pull/23513 ___ Python tracker <https://bugs.python.org/iss

<    1   2   3   4   5   6