[issue36962] Cant sort ModuleInfo instances

2019-05-19 Thread Eric V. Smith
Eric V. Smith added the comment: I agree. Sorry, BTaskaya, but I just don't think the benefit of this change is worth the disruption. -- resolution: -> wont fix stage: patch review -> resolved status: open -> closed ___ Python tracker

[issue36962] Cant sort ModuleInfo instances

2019-05-19 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Dataclasses are even more heavyweight than namedtuples. I am not sure that they should be used in the stdlib now. Especially in this case. I think the common use of iter_modules() is immediate unpacking of the yielded tuple: for importer, modname,

[issue36962] Cant sort ModuleInfo instances

2019-05-19 Thread Berker Peksag
Berker Peksag added the comment: I agree with Eric that this use case can be easily covered by using sorted(..., key=...). I suggest closing this as 'rejected'. -- nosy: +berker.peksag ___ Python tracker

[issue36962] Cant sort ModuleInfo instances

2019-05-19 Thread Eric V. Smith
Eric V. Smith added the comment: I'm not sure all of this churn is worth it for an unusual use case that can be satisfied by: >>> sorted(pkgutil.iter_modules(None), key=lambda x: (x[1], x[2]) or even: >>> sorted(pkgutil.iter_modules(None), key=operator.itemgetter(1)) (assuming that ispkg

[issue36962] Cant sort ModuleInfo instances

2019-05-19 Thread Batuhan
Batuhan added the comment: Can you review the PR, i implemented it there. -- ___ Python tracker ___ ___ Python-bugs-list mailing

[issue36962] Cant sort ModuleInfo instances

2019-05-19 Thread Batuhan
Batuhan added the comment: You're right. I am thinking implementing 4 sequence methods (contains/len/iter/getitem) and set a depraction warning for them. We can remove this methods in next relase On Sun, May 19, 2019, 2:37 PM Eric V. Smith wrote: > > Eric V. Smith added the comment: > >

[issue36962] Cant sort ModuleInfo instances

2019-05-19 Thread Eric V. Smith
Eric V. Smith added the comment: Unfortunately your change isn't backward compatible with the existing (namedtuple) version. I expect this to fail in the dataclass version: >>> finder, name, ispkg = list(pkgutil.iter_modules(None))[0] And since this is an enhancement, it can only go in to

[issue36962] Cant sort ModuleInfo instances

2019-05-18 Thread Batuhan
Change by Batuhan : -- keywords: +patch pull_requests: +13325 stage: -> patch review ___ Python tracker ___ ___ Python-bugs-list

[issue36962] Cant sort ModuleInfo instances

2019-05-18 Thread Batuhan
Batuhan added the comment: I think dataclasses can be used to do it with order, frozen true parameters. Also a __getitem__ is required for doesnt break anything. -- ___ Python tracker

[issue36962] Cant sort ModuleInfo instances

2019-05-18 Thread Batuhan
New submission from Batuhan : I can't sort the result of iter_modules; >>> import random, pkgutil >>> modules = list(pkgutil.iter_modules(None)) >>> random.shuffle(modules) >>> sorted(modules) Traceback (most recent call last): File "", line 1, in TypeError: '<' not supported between