Jun

Results 164 comments of Jun

# 0x01 运行Python 一旦完成了所有的初始化,Py_Main 函数会调用 pymain_run_python 函数开始运行。 ```c static void pymain_run_python(_PyMain *pymain) { PyCompilerFlags cf = {.cf_flags = 0}; pymain_header(pymain); pymain_import_readline(pymain); if (pymain->command) { pymain->status = pymain_run_command(pymain->command, &cf); } else...

@roachsinai > 上面的pymain_run_file应该是pymain_run_python? thx, 修正了

# apiserver > Library for writing a Kubernetes-style API server. https://github.com/Junnplus/blog/issues/44

# apiextensions-apiserver

## 初始化 server 配置 ### 默认配置 `initServerConfig` 函数初始化 redisServer 结构体,为 server 的一些配置项属性设置默认值以及初始化命令表: ```c void initServerConfig(void) { ... /* Command table -- we initiialize it here as it is part of...

## 初始化 server `initServer` 函数初始化 server 的状态,比如: ### 信号处理相关 ```c signal(SIGHUP, SIG_IGN); // 忽略 SIGHUP 信号 signal(SIGPIPE, SIG_IGN); // 忽略 SIGPIPE 信号 setupSignalHandlers(); // 注册信号处理器 ``` ### 客户端相关 ```c server.current_client...

## 启动事件循环 ```c // 5.0.3/src/ae.c void aeMain(aeEventLoop *eventLoop) { eventLoop->stop = 0; while (!eventLoop->stop) { if (eventLoop->beforesleep != NULL) eventLoop->beforesleep(eventLoop); aeProcessEvents(eventLoop, AE_ALL_EVENTS|AE_CALL_AFTER_SLEEP); } } ```

@lingmm 不懂java,23333

@Panlq intern 机制和 PyDict_SetDefault 没有关系的,PyDict_SetDefault 只是 dict 的一个操作而已。 intern 的机制其实和编译时期有关,具体的代码在 Objects/codeobject.c 里面 ```c // Objects/codeobject.c /* Intern selected string constants */ static int intern_string_constants(PyObject *tuple) { int modified = 0;...

另外,Python在编译器会优化字节码,像 ```py In [1]: a = 'hello' + 'python' In [2]: b = 'hellopython' In [3]: id(a), id(b) Out[3]: (4440501936, 4440501936) In [4]: 'hello ' + 'python' is 'hello python'...