New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pythonic submodules architecture #198
Conversation
Codecov Report
@@ Coverage Diff @@
## master #198 +/- ##
=========================================
Coverage ? 77.81%
=========================================
Files ? 9
Lines ? 622
Branches ? 115
=========================================
Hits ? 484
Misses ? 137
Partials ? 1 Continue to review full report at Codecov.
|
A very interesting slides presentation about successful APIs such as request: https://speakerdeck.com/kennethreitz/python-for-humans We indeed keep the API as the most important objective of All that is to say that if anybody has any idea on how to further enhance the |
Talking about API, here's a maybe interesting module to generate documentation (but it seems like it's reinventing the wheel, can't see the difference with doxygen...): |
|
About Line 91 in 50fc2d8
It's currently used only for the perf test to ensure that core |
Type hints are very cool, this brings pure Python closer to Cython and Julia, but it's unfortunately only available for Python >= 3.5.2 right now. Maybe it will be backported to Python 2 in the future (although MyPy already backported it)? Also, we would have to ponder whether the added verbosity (and thus code obfuscation) is worth the tradeoff (for the moment, typing is not really useful in Python but I guess it will be in the future for performance optimizers such as PyPy). Also, |
@lrq3000 As I said, include stub files. You can provide Some issues you mentioned
|
Ah great! I didn't see that separate stub files were possible (I thought they were talking about stub like in the sense of unit tests). About PyPy and Cython not using type hints, yes I just saw that here :( Ok great, so here is the provisional TODO list to implement type hinting in (moved to #260). /EDIT: I need to moderate a bit my excitement because it seems the current Python 3.5.2 implementation of type hints is only provisional and meant to get evolved in 3.6/3.7, particularly for duck typing support. Also,
So yeah, we can try to implement the stub files but we shouldn't expect too much out of them at least until 3.6, then we'll see if they get more useful. |
I tried to install and use So for the moment I'll drop this until it matures a bit more. Because I can't implement something that I cannot test. |
@lrq3000 try on Unix? Are you using Cygwin? and get a $5 raspberry pi for testing (raspian preinstalled), python isn't that great with windows |
@lrq3000 It may be a pain, but it really does help my editor a lot. Seriously, I type annotate every function I write, and I won't be using the code in a week. It's already a stable feature, and don't worry about incompatibility: you can just delete the Do it! I'm tempted to open a PR just for this! One time I even wrote a wrapper just for the type annotations for a library function. Try the PyCharm editor. It is really good at inferring types until you get to library functions. It's a hassle to deal with. |
Given the new insight about the performance impact of the current architecture of Hopefully, I would like to push before the end of September this PR as v5.0 along with #250, #257 (and maybe #244 if OK for you Casper) and include new submodules in alpha stage as #248, #258. We should leave #251 (monitoring thread) and other PRs for later. |
About #258 maybe not now, in fact it's almost ready, we just have to choose whether we keep functional tqdm_bare or class-based tqdm_bare_class, and then just copy some unit tests. So if it can be done for v5.0 that would be great but if not ready we'll leave it for later. I think this PR is of utmost importance, we should not move forward with new submodules until we have merged this PR. |
@lrq3000 this is quite old already |
Yes but it's a major change to the API, it's normal that it takes time. But I don't want to go further without @casperdcl 's approval, I think we should both agree when we do any change to the API architecture. |
Oh hello. Since filtering all tqdm emails I haven't been up to date with this. What's the order of things you'd like reviewed/merged, @lrq3000 ? |
@casperdcl The opposite, #198 should be last (because else we will have to recode manually the other PRs I think). I can manually redo #198 once the others are merged. |
@casperdcl Except #198 that should be last, the order is correct. |
6ec00f1
to
4b6476a
Compare
proposed submodule structure:
additionally, for a transition period:
|
@casperdcl |
k's, will change it |
Move the content of #610 here. Since some critical errors are reported, which are all related to TMonitor, global thread, or global tqdm.__instances set. Perhaps, it is better to provide a simple version (maybe
Indeed, it will not have some good features such as auto refresh, but it won't cause complicated errors). And then, tqdm with all features can be constructed on the basis of the simple version. For instance, the |
@casperdcl maybe also consider #604 (nosetest to pytest for test cases)? And use py3 to run performance tests (as py2.7 is going to be outdated)? |
`auto` will be able to support alternative backends in future - 97a9393#commitcomment-29850169 - 97a9393#commitcomment-30466004 - related to #198
Should fix #176, #245 and the second issue in #188 by reorganizing tqdm modules with a more pythonic architecture. This will allow a small performance boost (for all modules including core) as noted in #258 (comment).
The main goal of reorganizing tqdm's modules architecture is to avoid unnecessary imports without relying on delayed imports nor wrappers (which bring a whole lot of other issues, like no help message in IPython or other interpreters and the inability to call class methods such as
tqdm_notebook.write()
).The minor goal is to take this reorganization opportunity to enhance the overall API (uniformization for example, but if you have other ideas/complaints, please shout out in the discussion!).
Basically, I implemented the architecture suggested by @wernight:
_tqdm_notebook.py
->notebook.py
):__all__
were removed from__init__.py
tqdm()
andtrange()
, this uniformizes the usage oftqdm
across all modules. For example, it will ease the end-user implementation of adapting import codes.Before:
Now:
Note that I don't consider this change mandatory, but I wanted to profit of the opportunity that we are anyway changing the library architecture to see if API uniformization could be done. I am very open to feedback about this.
__init__.py
still imports and exposetqdm.core
as the default tqdm, so the old API for the core module is still compatible:This also implies that
tqdm.core
is always imported even if the user only uses a submodule such astqdm.gui
, but since anyway all current submodules subclass fromtqdm.core
, this doesn't change anything (and anyway importingtqdm.core
is not really heavy since it doesn't rely on any third party module...).Do you find this new architecture and API easier to use? Any feedback is welcome! (Users are also welcome to participate!)
TODO:
examples/
scripts.