[Python-ideas] function annotation enhancement

2019-03-19 Thread Tim Mitchell
I would like to propose an enhancement to function annotations. Here is the motivating use case: When using callbacks I would like to declare the signature once as a type alias and use it to type hint both the function accepting the callback and the callbacks themselves. Currently I can declare

[Python-ideas] singledispatch for methods

2019-03-26 Thread Tim Mitchell
Hi All, functools.singledispatch does not work on methods. There are 2 packages that do this for methods one on GitHub only https://gist.github.com/adamnew123456/9218f99ba35da225ca11 and my pypi package https://pypi.org/project/methoddispatch/. There are also a couple of stack overflow posts abou

Re: [Python-ideas] singledispatch for methods

2019-03-27 Thread Tim Mitchell
019, 1:09 PM Tim Mitchell > wrote: > >> Is it time to add singledispatch for methods to the core library? >> > > What's the motivation for it, beyond the fact that it's possible? > > Regarding jargon, aren't Python's instance methods are already &g

[Python-ideas] singledispatch for instance methods

2016-09-19 Thread Tim Mitchell
Hi All, We have a modified version of singledispatch at work which works for methods as well as functions. We have open-sourced it as methoddispatch (pypi: https://pypi.python.org/pypi/methoddispatch). IMHO I thought it would make a nice addition to python stdlib. What does everyone else think?

Re: [Python-ideas] A better interactive prompt

2016-10-26 Thread Tim Mitchell
Mark, Windows folk do not type pip install ipython On windows it's much easier: 1) install pycharm (because it has UI for installing packages) 2) Go to settings > project interpreter 3) select the python interpeter you want to use 4) click the + button 5) search through the entire pypi listing f

Re: [Python-ideas] Small improvements to the profile/cProfile API

2016-11-02 Thread Tim Mitchell
tringIO() > stats = pstats.Stats(self, stream=stream) > stats.sort_stats(*sort_keys) > if strip_dirs: > stats.strip_dirs() > stats.print_stats(*restrictions) > return stream.getvalue() > > # Define __enter__ and __exit__ to enabl

Re: [Python-ideas] Small improvements to the profile/cProfile API

2016-11-02 Thread Tim Mitchell
hen and where to print the output? Can you post the source for > your decorator? > > On Wed, Nov 2, 2016 at 4:52 PM, Tim Mitchell > wrote: > >> I use an @profile() decorator for almost all my profiling. If you want >> to profile function foo you just decorate it and re-