SQLite3 might work. The Python interface does support the in-memory implementation that the SQLite3 C API offers.
From the spec:
You can also supply the special name
:memory: to create a database in RAM.
It's also relatively cheap with transactions, depending on what you are doing. To get going, just:
import sqlite3
conn = sqlite3.connect(':memory:')
You can then proceed like you were using a regular database.
Depending on your data - if you can get by with key/value (strings, hashes, lists, sets, sorted sets, etc) - Redis might be another option to explore (as you mentioned that you wanted to share with other programs).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…