[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 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[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, ispkg in pkgutil.iter_modules():
...

Your change breaks it.

I agree with Eric and Berker that this issue should be closed.

--
nosy: +serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[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 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[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 doesn't really need to be part of the key)

Before reviewing the patch, I suggest you raise the issue on python-dev and get 
some additional input.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[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 list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[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:
>
> 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 3.8. And the window
> is closing for that, so it's more likely to be 3.9, if we decide that
> backward compatibility isn't important here.
>
> --
> nosy: +eric.smith
> type:  -> enhancement
> versions:  -Python 3.6, Python 3.7
>
> ___
> Python tracker 
> 
> ___
>

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[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 3.8. And the window is 
closing for that, so it's more likely to be 3.9, if we decide that backward 
compatibility isn't important here.

--
nosy: +eric.smith
type:  -> enhancement
versions:  -Python 3.6, Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[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 mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[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 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[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 instances of 'FileFinder' and 'FileFinder'

--
components: Library (Lib)
messages: 342830
nosy: BTaskaya
priority: normal
severity: normal
status: open
title: Cant sort ModuleInfo instances
versions: Python 3.6, Python 3.7, Python 3.8

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com