Skip to content

Instantly share code, notes, and snippets.

View tnakazato's full-sized avatar

tnakazato

  • National Astronomical Observatory of Japan
  • Tokyo
View GitHub Profile
@tnakazato
tnakazato / casa-frequency-conversion.ipynb
Last active March 4, 2024 02:32
CASA frequency conversion tutorial #ALMA #python
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tnakazato
tnakazato / EmulateSynthesisImaging.ipynb
Last active November 23, 2022 10:27
電波干渉計の画像復元アルゴリズムをごく簡単にPythonでコーディングしました
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tnakazato
tnakazato / EmulateRadioInterferometry.ipynb
Created November 21, 2022 06:32
電波干渉計の観測をPythonコードで表現してみました
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tnakazato
tnakazato / python_asyncio.ipynb
Created March 7, 2022 01:22
Asynchronous Python Processing without Blocking Call #python #asyncio
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tnakazato
tnakazato / HLTau_demo.ipynb
Last active August 9, 2022 02:43
PRIISM imaging demo: HL Tau #python #PRIISM #ALMA
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tnakazato
tnakazato / pydict-setitem.md
Last active November 15, 2021 07:54
pydict-setitem #python #c-api

How PyDict_SetItem handles a reference to key

Python function PyDict_SetItem is used to insert a value val into the dictionary with a key of key. According to the API document, PyDict_SetItem does not steal a reference to val so that the caller of PyDict_SetItem keeps an ownership of val. Hence, a reference to val must be decremented after it is added to the dictionary. But there is no mention about key in the API document. What should we do for key?

PyObject *dict = PyDict_New();
PyObject *key = PyUnicode_FromString("key");
PyObject *val = PyLong_FromLong(0L);

PyDict_SetItem(dict, key, val);