Наверняка вы замечали, что в Python есть удобная функция для получения переменной окружения
os.getenv(NAME)
И её "сестра" для создания или изменения переменных окружения
os.putenv(NAME, VALUE)
Но почему-то putenv() не работает как должно. Энвайромент не обновляется!
os.putenv('MYVAR', '1')
print(os.getenv('MYVAR'))
... и ничего 😴
Почему так?
На самом деле энвайромент обновляется, но это значение не добавляется в словарь os.environ.
Откройте исходник функции os.getenv(). Это просто шорткат для os.environ.get()
В то время как putenv() это built-in С-функция.
Словарь os.environ (или точней класс из MutableMapping) создаётся из энвайромента в момент инициализации. Функция putenv() самостоятельно его не изменяет.
В тоже время, когда вы создаёте или изменяете ключ в os.environ, автоматически вызывается putenv() в методе __setitem__().
То есть, технически putenv() всё делает верно, но в os.environ это не отражается. Можно проверить так:
>>> os.putenv('MYVAR', '123')
>>> os.system('python -c "import os;print(os.getenv(\'MYVAR\'))"')
123
Я объявил переменную в текущем процессе и вызвал дочерний процесс, который её унаследовал и получил в составе os.environ.
Аналогично при удалении переменной вызывается еще одна built-in функция unsetenv(), удаляющая переменную из системы.
Итого
▫️ Удобней всего явно обновлять переменные через os.environ
▫️ Есть способ неявно создать/удалить переменную через putenv/unsetenv, что не повлияет на os.environ но изменит энвайромент и передаст изменения сабпроцессам. Но так лучше не делать!
▫️os.environ это просто обертка для built-in функций putenv() и unsetenv().
#basic
被CMSIS-DSP的FFT创飞 (其实是没仔细读文档
arm官方文档明确指出了 arm_rfft_fast_f32 会原地修改输入缓冲区, 然而咱用库之前没仔细读文档
Due to the use of complex transform internally, the source buffer is modified by the rfft.
看到函数参数有输入和输出指针, 然后就想当然认为函数内部一定不会覆盖输入缓冲区, 再加上输入循环缓冲用的是zero-copy, 调用FFT也是直接传入了缓冲区指针, 所以相当于算了一次FFT后直接污染了整个缓冲区
#Debug
#debug#洋屁
playing Valheim with friends
started a Linux Dedicated Server w/ Azure Playfab Crossplay Support.
can't connect server using IP and Playfab API always connecting
> Unable to preload the following plugins: libparty.so
checking libparty.so using > ldd libparty.so
IT NEEDS libpulse-dev ???????
Why? Audio lib requested SRSLY?
sudo apt install libpulse-dev
all works...
https://pypi.python.org/pypi/django-debug-toolbar
A configurable set of panels that display various #debug information about the current #request/#response.
The #Django_Debug_Toolbar is a configurable set of panels that display various debug information about the current request/response and when clicked, display more details about the panel’s content.
Here’s a screenshot of the toolbar in action:
#swift#analysis#analytics#cocoapods#crashlytics#debug#debugger#debugging#hacktoberfest#layout_debugger#leak_detection#log#logs_analysis#networking#performance_analysis#sandbox#swift#swift6#ui#uikit#view
DebugSwift is a comprehensive toolkit that simplifies debugging for Swift iOS apps by providing real-time monitoring of network requests, performance metrics (CPU, memory, FPS), crash reports, and app resources like keychain and user defaults. It includes interface tools for visualizing layouts with grid overlays and touch indicators, plus memory leak detection and console logging. The main benefit is that you can quickly identify and fix issues during development without leaving your app—just shake your device to toggle the debug panel, making troubleshooting faster and more efficient.
https://github.com/DebugSwift/DebugSwift