On 24.05.2020 13:27, Ram Rachum wrote:
> Hi everyone,
> 
> I submitted a PR today, and Serhiy decided it needs a discussion on
> python-ideas and agreement from core developers before it could go forward.
> 
> BPO: https://bugs.python.org/issue40752 
> PR: https://github.com/python/cpython/pull/20348
> 
> Today I wrote a script and did this:
> 
>     sorted(paths, key=lambda path: len(str(path)), reverse=True)
> 
> But it would have been nicer if I could do this:
> 
>     sorted(paths, key=len, reverse=True)
> 
> So I implemented `PurePath.__len__` as `str(len(path))`.
> 
> Serhiy and Remi objected, because it might not be obvious that the
> length of the path would be the length of string. 
> 
> What do you think? Can I get some +1s and -1s for this change?

It would be surprising to have an object which implements .__len__(),
but otherwise doesn't allow any indexing, so -1 on such a change.

If Paths ever get indexing, it would also be more natural to
have those indexes refer to path components. The .__len__()
would have to map to the number of path components, not the length
of a string representation.

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Experts (#1, May 24 2020)
>>> Python Projects, Coaching and Support ...    https://www.egenix.com/
>>> Python Product Development ...        https://consulting.egenix.com/
________________________________________________________________________

::: We implement business ideas - efficiently in both time and costs :::

   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
    D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
           Registered at Amtsgericht Duesseldorf: HRB 46611
               https://www.egenix.com/company/contact/
                     https://www.malemburg.com/
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/2NBY2UTHRRF5S3Z7T7NPG5W224H7PUF5/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to