JPype, py4j and PyJNIus are all good options for Java interface for Python. Jpype is easy to use and widely adopted. PyJNIus is an even easier solution compred to JPype. py4j is more complicated to use compared to JPype and PyJNIus, however, it has a better performance, generally speaking.
Concurrency and Parallel Computing in Python
The GIL is controversial because it prevents multithreaded CPython programs from taking full advantage of multiprocessor systems in certain situations. Note that potentially blocking or long-running operations, such as I/O, image processing, and NumPy number crunching, happen outside the GIL. Therefore it is only in multithreaded programs that spend …
Relative Import in Python
** Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement! **
-
Call the package outside it
-
Add
..intosys.path.:::python import sys sys.path.append("..")
References
Runtime Paths in Python
__file__ is the path of the Python script.
Note that if you make a sybolic link to a Python script and run the symbolic link,
then __file__ is the path of the symbolic link.
Of course, you can use os.path.realpath to get real path of files.
pathlib.Path …
Select Columns from Structured Text Files
Python pandas
My first choice is pandas in Python. However, below are some tools for quick and dirty solutions.
q
q -t -H 'select c1, c3 from file.txt'
cut
cut -d\t -f1,3 file.txt
awk
awk -F'\t' '{print $1 "\t" $3}' file.tsv
Note: neither cut …
Get Group Names on Linux/Unix
Linux
-
Get information of the
staffgroup.$ getent group staff staff:x:20: -
Get group ID of the
staffgroup.$ getent group staff | cut -d: -f3 20
Mac
-
Get information of the
staffgroup.$ dscl . -read /Groups/staff -
Get group ID of the
staffgroup.$ dscl . -read /Groups/staff | awk …