On Mon, Dec 20, 2021 at 1:42 PM Mark Shannon <m...@hotpy.org> wrote:

> OOI, of those 1577 Callable type hints, how many distinct Callable types?
>
>
Good question. About 30 callables for source code itself and an additional
60 for pytest factory fixtures.


> On 20/12/2021 7:52 am, Andrew Svetlov wrote:
> > At my job, we have 1577 Callable type hints scattered in 1063 Python
> files.
> > For comparison, this codebase also has 2754 dict annotations and 1835
> list ones.
> >
> > On Mon, Dec 20, 2021 at 8:11 AM Christopher Barker <python...@gmail.com
> <mailto:python...@gmail.com>> wrote:
> >
> >     note: I wasn't thinking -- typeshed, of course, has a lot more than
> the standard lib.  But it's still a collection of widely used somewhat
> general purpose libraries. So I think my hypothesis is still valid.
> >
> >     -CHB
> >
> >
> >     On Sun, Dec 19, 2021 at 8:54 PM Christopher Barker <
> python...@gmail.com <mailto:python...@gmail.com>> wrote:
> >
> >         A question that came up for me is:
> >
> >         How common is it to need to use Callable for type hints?
> particularly complex versions, specifying what parameters the Callable
> takes? A more compact and easier to read syntax is nice, but not very
> important if it isn't used much.
> >
> >         My first thought on this was that I can't remember a single time
> that I wrote production code that took a Callable as a function parameter
> -- or returned one -- OK maybe a few times, but it's certainly rare in my
> production code.
> >
> >         So I looked in the PEP to see if that issue was addressed, and
> indeed it is:
> >
> >         "The Callable type is widely used. For example, as of October
> 2021 it was the fifth most common complex type in typeshed,"
> >
> >         That did surprise me, but on thinking about it, maybe not so
> much. It strikes me that Callable is most likely to be used in fairly low
> level, general purpose functions, like map(), sort(), various functions in
> itertools, etc. Just the sort of functions that are common in the standard
> library, but may not so much in production code.
> >
> >         I have no idea how to evaluate how common it is in production
> code -- maybe type hinting is common enough now  that PyPi could be
> searched -- but even PyPi is a biased sample, as it is full of, by
> definition, libraries for others' use -- i.e. general purpose tools (less
> general that the stad lib, but still not specialty production code, which I
> suspect is the majority of Python code out there).
> >
> >         Perhaps some folks that have been type=hinting their production
> code bases could provide anecdotal evidence.
> >
> >         Anyway, if my hypothesis is correct, then it's not so bad that
> not-so-nice syntax is required to type hint general purpose utilities.
> >
> >         -CHB
> >
> >         --
> >         Christopher Barker, PhD (Chris)
> >
> >         Python Language Consulting
> >            - Teaching
> >            - Scientific Software Development
> >            - Desktop GUI and Web Development
> >            - wxPython, numpy, scipy, Cython
> >
> >
> >
> >     --
> >     Christopher Barker, PhD (Chris)
> >
> >     Python Language Consulting
> >        - Teaching
> >        - Scientific Software Development
> >        - Desktop GUI and Web Development
> >        - wxPython, numpy, scipy, Cython
> >     _______________________________________________
> >     Python-Dev mailing list -- python-dev@python.org <mailto:
> python-dev@python.org>
> >     To unsubscribe send an email to python-dev-le...@python.org <mailto:
> python-dev-le...@python.org>
> >     https://mail.python.org/mailman3/lists/python-dev.python.org/ <
> https://mail.python.org/mailman3/lists/python-dev.python.org/>
> >     Message archived at
> https://mail.python.org/archives/list/python-dev@python.org/message/LWIXFDUGRM6Z3KHI3YGV65HWXRD2S4H5/
> <
> https://mail.python.org/archives/list/python-dev@python.org/message/LWIXFDUGRM6Z3KHI3YGV65HWXRD2S4H5/
> >
> >     Code of Conduct: http://python.org/psf/codeofconduct/ <
> http://python.org/psf/codeofconduct/>
> >
> >
> >
> > --
> > Thanks,
> > Andrew Svetlov
> >
> > _______________________________________________
> > Python-Dev mailing list -- python-dev@python.org
> > To unsubscribe send an email to python-dev-le...@python.org
> > https://mail.python.org/mailman3/lists/python-dev.python.org/
> > Message archived at
> https://mail.python.org/archives/list/python-dev@python.org/message/JYZGIDEBV4R5E7XXT3KFS2O545TDTAGT/
> > Code of Conduct: http://python.org/psf/codeofconduct/
> >
>


-- 
Thanks,
Andrew Svetlov
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/MG2PKYBIZHA3PPEVWJMSXR4WJ4TLBKVZ/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to