"Mutable and Immutable Types" example
还没有人认领这个 Issue。
评估
- 难度
- 1/5
- 预计耗时
- 1 小时以内
- 新手友好度
- 48/100
- Issue 类型
- 文档
- 描述清晰度
- 描述清楚
- 活跃度
- 停滞
- 技术栈
- python
调研方向
从链接的“Structuring Your Project”页面中的“Mutable and Immutable Types”部分开始,并将现有示例与提议的表达式进行比较。当文档使用约定的示例,并准确呈现任何性能方面的说法时,即视为完成。
由索引模型根据 Issue 内容生成。
描述
The best example in the Mutable and Immutable Types section of the Structuring Your Project page is:
# create a concatenated string from 0 to 19 (e.g. "012..1819")
nums = [str(n) for n in range(20)]
print "".join(nums)
It is considered the best example for being both more efficient and succinct.
Would this be a better example to use?
''.join(map(str, range(20)))
It's more succinct and is faster:
$ python -m timeit "nums = [str(n) for n in range(20)]; ''.join(nums)"
100000 loops, best of 3: 6.84 usec per loop
$ python -m timeit "''.join(map(str, range(20)))"
100000 loops, best of 3: 4.93 usec per loop
- 主要语言
- Batchfile
- 星标
- 29.8k
- 派生
- 5.9k
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
realpython/python-guide 的其他 Issue
-
Page 404 error 未关闭
难度 1/5 1 小时以内 新手友好度 65/100
realpython/python-guide#1104 · 2 条评论 ·
-
难度 1/5 1-3 小时 新手友好度 62/100
realpython/python-guide#327 ·
-
难度 2/5 1-3 小时 新手友好度 62/100
realpython/python-guide#326 · 5 条评论 ·
-
@alex 未关闭
难度 5/5 一周以上 新手友好度 10/100
realpython/python-guide#1194 ·
-
难度 5/5 一周以上 新手友好度 10/100
realpython/python-guide#1192 ·