Some Sessions from the Python Language Summit
lwn.net
lwn.net
Even though mobile phones have gotten fast, this is an severe issue with React Native apps. And Facebook is pouring in a lot of engineering to tackle it. But the progress is incremental at the best. As a result some code gets rewritten in C++ because of this issue (see e.g. Trust Wallet). Even though I love Python as a programming language I would not recommend it for consumer grade mobile application development and I feel it is unlikely to get there ever unless some breakthrough happens in runtime development.
I opened source the idea at https://github.com/joaoventura/pybridge
The thing that makes this different from a pure android python project is that I only use Python as a kind of mobile RPC backend. The UI is completely native in Java/Kotlin.
As a side note, today I’ve open sourced the same technique, but for iOS (https://news.ycombinator.com/item?id=23335704). I’m able to share all the python code but adapt the UI using the native tools..
Honest question: is there an example of a language that does C extensions well? As a professional programmer, I have worked at different times with C extensions in Node.js, Java, R, and Erlang, (in addition to Python). Erlang and Node.js were maybe ok, but had their own challenges.
The same is most likely true for other "scripting languages" where the main purpose is to add a scripting API to otherwise native applications (like Wren: https://github.com/wren-lang/wren)
With Hypothesis, you can combine those two tests into one, by letting Hypothesis generate the inputs for you. Hypothesis is pretty smart to find edge cases that you usually don't think of.
Overall, it reduce my time to write tests by at least half, maybe 75% even.
The caveats are: 1/ Tests may take visibly longer to run. 2/ If you have setup/teardown or fixtures that you want to repeat each generated input, you have to do this manually. This is imo the biggest weak point of Hypothesis right now.
https://github.com/pytest-dev/pytest/issues/916
It is a known issue. Basically your fixture/setup/teardown, which you expect should run for every example generated by Hypothesis, actually only run once.
This is worth reemphasizing.
For certain kinds of hard problems, I've found it really valuable for building confidence in an implementation.
If you happen to have a reference implementation, with a small surface API, it can be a very fast way to write tests: tell hypothesis to input anything it wants and validate that both libraries produce the same result. It's not magic, you will probably still have to give hints about how to build interesting inputs, but still a very quick way to get a lot of coverage. (Also be sure to crank up the number of examples to build more confidence, 100 is often not enough to really explore an input space).