/* Bytecode object */ struct PyCodeObject { PyObject_HEAD int co_argcount; /* #arguments, except *args 参数数量*/ int co_posonlyargcount; /* #positional only arguments */ int co_kwonlyargcount; /* #keyword only arguments 关键字参数个数*/ int co_nlocals; /* #local variables 局部变量个数*/ int co_stacksize; /* #entries needed for evaluation stack 执行代码所需栈数量*/ int co_flags; /* CO_..., see below 标识*/ int co_firstlineno; /* first source line number 代码块首行行号*/ PyObject *co_code; /* instruction opcodes 指令操作码,也就是字节码*/ PyObject *co_consts; /* list (constants used) 常量列表*/ PyObject *co_names; /* list of strings (names used) 全局变量名列表*/ PyObject *co_varnames; /* tuple of strings (local variable names) 局部变量名列表*/ PyObject *co_freevars; /* tuple of strings (free variable names) 闭包名字列表*/ PyObject *co_cellvars; /* tuple of strings (cell variable names) 被嵌套函数使用的名字列表*/ /* The rest aren't used in either hash or comparisons, except for co_name, used in both. This is done to preserve the name and line number for tracebacks and debuggers; otherwise, constant de-duplication would collapse identical functions/lambdas defined on different lines. */ Py_ssize_t *co_cell2arg; /* Maps cell vars which are arguments. */ PyObject *co_filename; /* unicode (where it was loaded from) 文件名*/ PyObject *co_name; /* unicode (name, for reference) 函数名*/ PyObject *co_linetable; /* string (encoding addr<->lineno mapping) See Objects/lnotab_notes.txt for details. */ void *co_zombieframe; /* for optimization only (see frameobject.c) */ PyObject *co_weakreflist; /* to support weakrefs to code objects */ /* Scratch space for extra data relating to the code object. Type is a void* to keep the format private in codeobject.c to force people to go through the proper APIs. */ void *co_extra;
/* Per opcodes just-in-time cache * * To reduce cache size, we use indirect mapping from opcode index to * cache object: * cache = co_opcache[co_opcache_map[next_instr - first_instr] - 1] */
// co_opcache_map is indexed by (next_instr - first_instr). // * 0 means there is no cache for this opcode. // * n > 0 means there is cache in co_opcache[n-1]. unsigned char *co_opcache_map; _PyOpcache *co_opcache; int co_opcache_flag; // used to determine when create a cache. unsigned char co_opcache_size; // length of co_opcache. };
>>> result.co_consts (3.14, <code object circle_area at 00000000036DBEB0, file "test.py", line 3>, 'Dog', <code object Dog at 00000000036E2A30, file "test.py", line 6>, None)
常量列表里 还有两个代码对象!其中一个是
circle_area 函数体,另一个是 Dog
类定义体。回忆一下 Python 作用域 的划分方式:
每个作用域对应着一个代码对象
!若假设成立, Dog
代码对象的常量列表应该还藏着两个代码对象,分别代表
init 方法和 yelp 方法的函数体:
事实确实如此:
1 2 3 4
>>> dog_code = result.co_consts[3] >>> dog_code.co_consts (<code object __init__ at 00000000036D48B0, file "test.py", line 8>, <code object yelp at 00000000036D49B0, file "test.py", line 11>) >>>
$ ls -li mssh_ip.sh 7120498 -rw-r--r-- 1 liuwen03 liuwen03 183 Jan 28 14:13 mssh_ip.sh
## 4. the size and the number of inode
inode也会消耗硬盘空间,所以硬盘格式化的时候,操作系统自动将硬盘分成两个区域。一个是
数据区,存放文件数据;另一个是inode区(inode
table),存放inode所包含的信息。
每个inode节点的size,一般是
128或256字节。inode节点的总数,在格式化时就给定,一般是每1KB或每2KB就设置一个inode。假定在一块1GB的硬盘中,每个inode节点的大小为128字节,每1KB就设置一个inode,那么inode
table的大小就会达到128MB,占整块硬盘的12.8%。
$ echo 'I am leo。my qq is xxxxxx' |awk -F '[ ,]+' '{print $3" "$7}' # 多个分隔符 leo xxxxxx
- 我们将字符串 i am so busy
通过管道传递给awk命令,相当于awk处理一个文件,该文件的内容就是i am so
busy,默认通过空格作为分隔符(不管列之间有多少个空格都将当作一个空格处理)i
am so busy就分割成四列了。 - 另外,我们发现pattern{ 命令
}中","输出时为空格" "。