zero323 / tryingsnake Goto Github PK
View Code? Open in Web Editor NEWException handling, the functional way.
License: MIT License
Exception handling, the functional way.
License: MIT License
It seems like adding type annotations (#5)
tryingsnake/tryingsnake/__init__.py
Line 10 in 10ea65e
caused rather unexpected performance regression:
Python 3.8.0 | packaged by conda-forge | (default, Nov 22 2019, 19:11:38)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.11.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import importlib
In [2]: !git checkout 3a25dba30a527476deb4bfbd3cfa88ccd2b977ee
Note: switching to '3a25dba30a527476deb4bfbd3cfa88ccd2b977ee'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:
git switch -c <new-branch-name>
Or undo this operation with:
git switch -
Turn off this advice by setting config variable advice.detachedHead to false
HEAD is now at 3a25dba Provide type annotations and apply required refactoring
In [3]: import tryingsnake
In [4]: %timeit for i in range(1_000): tryingsnake.Try(lambda x: x, 1)
1.36 ms ± 12.3 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
In [5]: !git checkout HEAD~1
Previous HEAD position was 3a25dba Provide type annotations and apply required refactoring
HEAD is now at a666744 Merge pull request #4 from zero323/failed
In [6]: importlib.reload(tryingsnake)
Out[6]: <module 'tryingsnake' from '/path/to/tryingsnake/tryingsnake/__init__.py'>
In [7]: %timeit for i in range(1_000): tryingsnake.Try(lambda x: x, 1)
668 µs ± 6.82 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
It seems that the main culprit is Generic[T]
added as a base class for Try_
.
Such overhead is rather unacceptable in practice, so unless it is considered a bug, and solved upstream, we should probably move annotations to stub files (401ec6f).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.