# Python @property 的源码分析

property 在 Python 中是一种装饰器,可以用来修饰方法

# 作用

我们可以使用 @property 装饰器来创建只读属性,@property 装饰器会将方法转换为相同名称的只读属性,可以与所定义的属性配合使用,以防止属性被修改

# Python zip()

# 我一般也不清楚如何形容一些方法的特性,都是在网上查查就过了,先看看 runoob 对 zip 的描述

zip() 用于将可迭代的对象作为参数,将对象中对应的元素打包成一个个元组,然后返回由这些元素组成的列表。如果各个迭代器的元素个数不一致,则返回的列表长度与最短的对象相同,利用 * 号操作符,可以将元组解压为列表

关于 zip 的简单用法可以参考:https://www.runoob.com/python/python-func-zip.html

# Python map

map 在 Python 中是一个内置类,在初始化时,第一个参数传递 function 对象,后面可以跟一个或多个序列参数

# What CPython is and why anyone would want to study it

CPython 是用 C 编写的 Python 解释器,它是 Python 的实现之一,CPython 的独特之处在于它是最原始、维护最多和最流行的一个。

CPython 实现了 Python,But what is Python?One may simply answer —— Python is a programming language。什么定义了 Python?Python 不像 C 这样的语言,它没有形式规范

# Range 的實現原理

老規矩,先看看 range 的 docstring

range(stop) -> range object
range(start, stop[, step]) -> range object
Return an object that produces a sequence of integers from start (inclusive)
to stop (exclusive) by step.  range(i, j) produces i, i+1, i+2, ..., j-1.
start defaults to 0, and stop is omitted!  range(4) produces 0, 1, 2, 3.
These are exactly the valid indices for a list of 4 elements.
When step is given, it specifies the increment (or decrement).