namedtuple or NamedTuple?
NamedTuple is a type-annotated namedtuple
Threading Condition Variable
Below is a demonstration of using a condition variable. The purpose of it is waiting on some condition to be met, related to a shared resource, and doing it in… Read more »
Python Function Inspection
Consider the following code: It produces the following output:
Python and C/C++ interop links
“Hello, World!” C-extension (my fork – no change, for backup) PyBind (C++ easy binding): The library Example – couldn’t make it work on my machine yet cppimport – usually using… Read more »
Python 2 -> 3 Links
https://docs.python.org/2/library/2to3.html https://sebastianraschka.com/Articles/2014_python_2_3_key_diff.html https://engineering.yoyowallet.com/yoyo-moves-to-python-3-df1d1692e694 http://python-future.org/compatible_idioms.html
Numpy/Pandas links
Performance http://numba.pydata.org/ A faster alternative to Pandas isin function Pandas performance Pandas iterrows alternatives (performance issues) Fast, Flexible, Easy and Intuitive: How to Speed Up Your Pandas Projects Misc Working… Read more »
Python profiling links (memory and CPU)
Tools: Tracemalloc, memory_profiler, meliae (Python 2 only), Pympler Built-in modules: gc Links: Python Memory Issues: Tips and Tricks Muppy toturial Debugging with Tracemalloc Using profilers – the basics Py-spy – top-like live view… Read more »
Coding interview tips (online oriented)
Doing an online coding interview, or even face-to-face one isn’t easy. It’s a skill you should master if you are looking for a job and I have gathered some tips that might help you improve it.
Generator Context Manager Pitfall
Consider the following context manager: The following code with print ‘bla’ between ENTERED and EXITED but will also raise the exception: That’s what I would expect from a context manager… Read more »