ParserBase could be optimized
@ezio-melotti 已經在處理了。
開始於 2022年5月1日。
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 36k
- 平均合併
- 1 天 9 小時
- 30 天內合併 PR
- 558
描述
There is a lot of wasteful CPU code in this fashion (seen multiple times) :-
if ")" in rawdata[j:]:
j = rawdata.find(")", j) + 1
search performed in string twice, even if we could just do it once.
Consider the strings immutable, then on every slice a new string is created on the fly.
Moreover, the slicing done at rawdata[j:], is bound to be quite expensive depending on the size of the string.
We could eliminate slicing altogether and only have one find operation in this style :-
RPAREN_pos = rawdata.find(")", j)
if find_RPAREN != -1:
j = RPAREN_pos + 1
I'm new to Open Source Code Contributions. Would love to learn from other's coding style & know other's point of view.
Originally posted by @be-thomas in https://github.com/python/cpython/issues/92084#issuecomment-1114023102
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
評估
這個 Issue 還沒有評估資料。