Profiling Python scripts (2): stlinfo
This is the second in a series of articles that covers analyzing and improving
performance bottlenecks in Python scripts.
In this second article the performance of stlinfo
is looked at.
This is the second in a series of articles that covers analyzing and improving
performance bottlenecks in Python scripts.
In this second article the performance of stlinfo
is looked at.
This is the first in a series of articles that covers analyzing and improving performance bottlenecks in Python scripts.
Installing Python scripts (as opposed to modules) is a too involved using distutils/setuptools. Those do not take into account zipped archives and scripts using a GUI toolkit. The latter is a problem on ms-windows.
So I wrote my own setup scripts to do things differently;
These scripts are now available on github as setup-py-script.
At work, we recently bought an EBI 40 TC-01 6-channel temperature logger.
It saves data in a file with the ed3
extension.
It comes with a ms-windows program to show the data and export to CSV and ms-excel.
However, I want to be able to use the data on my FreeBSD workstation.
So I have to figure out the data format of the ed3
files.
This article documents how I set up Python and the syslog daemon so that Python programs can log to syslogd.
Sometimes I need to use some binary data (e.g. a bitmap image) in a Python
script.
In a package, you can store this data portable in a data
subdirectory of
a modules using the package_data
argument of setuptools.setup
.
This won’t work in a standalone script.
You can of course make your script into a package, but here I want to show an
alternative solution.
As an exercise, I wrote a small script to read the Atom feeds for some favourite youtube channels. Of course I could have installed a “real” feed-reader, but that would be overkill and not half as much fun. :-)
In part 1 we say that a simple replacement for conky for generating
a statusline for i3 can be achieved. But since it uses the subprocess
module to call external programs it is pretty CPU intensive.
The question now is if we can reduce that? For that we’re going to use
mmap to look at the mailbox, and call sysctlbyname(3)
using ctypes to get the remaining system information. Note that sysctl
et
al and the names used are specific to FreeBSD.