blog
blog copied to clipboard
Junnplus's technology blog
终端下的工作流
因为大部分编码工作都是在终端下进行的,简单写一篇文章分享下自己的终端下的工作流。 Mac 下使用的终端是 iTerm2,配置了打开一个 iTerm2 窗口会自动执行 `workup` 命令列出可选的工作空间。这里需要解释一下,我的一个工作空间是一个特定的目录,大多数场景是指一个 Git 仓库。 `workup` 命令结合了 tmux + fzf 命令支持: - 快速搜索工作空间 - 进去已有工作空间 - 新建一个新的工作空间(输入一个不存在的工作空间之后回车即可) 一个工作空间是由一个 tmux session 加若干个 tmux window/pane 组成,这样就可以通过管理 iTerm2...
Mysql 的主從複製原理見下圖  `Replication` 是一個異步的複製過程,所謂異步,是指系統更新到 Master 的內容並一定會及時的反映到 Slave 上。 ### Slave 的 I/O 線程和 SQL 線程 Slave 上會同時有兩個線程在工作, I/O 線程從 Master 得到數據(`Binary Log` 文件),放到被稱爲 `Relay Log` 文件中進行記錄。另一方面,SQL 線程則將 `Relay Log`...
> Python中字符串对象和整数对象一样,都是不可变对象`immutable`。 Python2中的字符串有两种:普通字符串(`8-bit strings`)和Unicode字符串(`unicode strings`),分别对应着`str`(`PyStringObject`)和`unicode`(`PyUnicodeObject`)两个字符串对象,都是抽象类型`basestring`的子类: ```python >>> str.__base__ >>> unicode.__base__ ``` > basestring() This abstract type is the superclass for str and unicode. It cannot be called or instantiated, but...
## arena 内存池 (arena的管理) 我们来看看arena是如何被管理的。 ```c /*========================================================================== Arena management. `arenas` is a vector of arena_objects. It contains maxarenas entries, some of which may not be currently used (== they're arena_objects...
```python print('Hello, World') def hello(): print('world') ``` ```python >>> co = compile(open('hello.py').read(), 'hello.py', 'exec') >>> co >>> type(co) ``` Python代码在Python解释器中是以`code`对象存在的。 ``就是`PyCodeObject`对象,定义在`Include/code.h`: ```c /* Bytecode object */ typedef struct { PyObject_HEAD...
> python中一切都是“对象” # 0x00 PyObject `PyObject`定义在`Include/object.h`,我们来看看这个对象。 ```c typedef struct _object { _PyObject_HEAD_EXTRA Py_ssize_t ob_refcnt; struct _typeobject *ob_type; } PyObject; ``` PyObject中有两个成员的结构体, - `ob_refcnt`,引用记数 - `ob_type`,类型对象的指针 其类型分别为`Py_ssize_t`和`struct _typeobject` ## Py_ssize_t 从名字可以看得出来,`ob_refcnt`就是Python的内存管理机制中基于引用计数的垃圾回收机制的对象引用数。...
# 0x00 引用计数 > 在Python中,大多数对象的生命周期都是通过对象的引用计数来管理的。 ## 增引用操作 ```c #define Py_INCREF(op) ( \ _Py_INC_REFTOTAL _Py_REF_DEBUG_COMMA \ ((PyObject *)(op))->ob_refcnt++) ``` ## 减引用操作 ```c #define Py_DECREF(op) \ do { \ PyObject *_py_decref_tmp =...
Python3中的整数对象`PyLongObject`定义在`Include/longobject.h`: ```c /* Long (arbitrary precision) integer object interface */ typedef struct _longobject PyLongObject; /* Revealed in longintrepr.h */ ``` `_longobject`具体实现在`Include/longintrepr.h`: ```c struct _longobject { PyObject_VAR_HEAD digit ob_digit[1]; }; ```...
Redis 的字典(dict)使用哈希表(hashtable)作为底层实现: ```c // 5.0.3/src/dict.h /* This is our hash table structure. Every dictionary has two of this as we * implement incremental rehashing, for the old to the new...
gunicorn源码解析
> Gunicorn 'Green Unicorn' is a Python WSGI HTTP Server for UNIX. It's a pre-fork worker model. The Gunicorn server is broadly compatible with various web frameworks, simply implemented, light...