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
Change by Ken Jin :
--
pull_requests: +21980
pull_request: https://github.com/python/cpython/pull/23061
___
Python tracker
<https://bugs.python.org/issue42
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!
--
_
Change by Ken Jin :
--
pull_requests: +21982
pull_request: https://github.com/python/cpython/pull/23063
___
Python tracker
<https://bugs.python.org/issue42
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
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 "",
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
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
Change by Ken Jin :
--
pull_requests: +21999
pull_request: https://github.com/python/cpython/pull/23081
___
Python tracker
<https://bugs.python.org/issue42
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
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
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
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
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
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
Change by Ken Jin :
--
resolution: -> fixed
stage: patch review -> resolved
status: open -> closed
___
Python tracker
<https://bugs.python.or
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
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
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
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
Ken Jin added the comment:
Dominik, would you like to submit a PR for this :) ?
--
___
Python tracker
<https://bugs.python.org/issue42317>
___
___
Python-bug
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
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
Change by Ken Jin :
--
pull_requests: +22200
pull_request: https://github.com/python/cpython/pull/23309
___
Python tracker
<https://bugs.python.org/issue42
Change by Ken Jin :
--
pull_requests: +22278
pull_request: https://github.com/python/cpython/pull/23385
___
Python tracker
<https://bugs.python.org/issue42
Change by Ken Jin :
--
pull_requests: +22279
pull_request: https://github.com/python/cpython/pull/23386
___
Python tracker
<https://bugs.python.org/issue42
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
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
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
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
501 - 530 of 530 matches
Mail list logo