prm 最近的时间轴更新
prm's repos on GitHub
Elixir · 48 人关注
abnf_parsec
ABNF in, parser out
Elixir · 26 人关注
clusterable
Prepare elixir/erlang nodes to be clustered
Elixir · 13 人关注
cookie_jar
CookieJar stores your cookies and applies them to future requests
Elixir · 1 人关注
aoc
Ruby · 1 人关注
cighate
I hate cigarettes, who wants to second me?
Elixir · 0 人关注
2022-abnf-parsec-scim-filter-issue
Shell · 0 人关注
alpine-caddy
Alpine Linux Docker Container running Caddyserver
TypeScript · 0 人关注
angular
One framework. Mobile & desktop.
CSS · 0 人关注
angular-talk
In house angular talk at Zendesk Melbourne Office.
JavaScript · 0 人关注
angular.js
HTML enhanced for web apps
Elixir · 0 人关注
arc
:paperclip: Flexible file upload and attachment library for Elixir
Elixir · 0 人关注
awesome-elixir
A curated list of amazingly awesome Elixir and Erlang libraries, resources and shiny things. Updates:
0 人关注
ayu
🎨🖌 Modern Sublime Text theme
Elixir · 0 人关注
bamboo
Testable, composable, and adapter based elixir email library for devs that love piping.
TypeScript · 0 人关注
basky
Basketball score keeping Angular app
0 人关注
bob
The Builder
Python · 0 人关注
BracketHighlighter
Bracket and tag highlighter for Sublime Text
0 人关注
cache-handler
Distributed HTTP caching module for Caddy
Elixir · 0 人关注
cachex
A powerful caching library for Elixir with support for transactions, fallbacks and expirations -
Go · 0 人关注
caddy-filemanager
:file_folder: Caddy plugin that provides a file manager
HTML · 0 人关注
caddyserver.com
Source of the Caddy website
Elixir · 0 人关注
calecto
Adapter for the Calendar library in Ecto
Elixir · 0 人关注
calendar
date-time and time zone handling in Elixir
0 人关注
canvas
A library for declarative use of Canvas API with Angular
Elixir · 0 人关注
castore
Up-to-date certificate store for Elixir. 🔐
Elixir · 0 人关注
codepagex
Elixir string encoding conversion - like iconv but pure Elixir
Python · 0 人关注
ColorHelper
Sublime plugin that provides helpful color tooltips
Rust · 0 人关注
crates.io
Source code for crates.io
Elixir · 0 人关注
csv
CSV Decoding and Encoding for Elixir
Python · 0 人关注
curio
prm

prm

V2EX 第 177065 号会员,加入于 2016-06-12 18:36:10 +08:00
prm 最近回复了
2016-07-25 23:08:01 +08:00
回复了 strahe 创建的主题 Python 关于 Python 的一个问题
归根结底这是 Python 语言设计的锅, python 定义了与各种 operator 等价的 magic method (双下划线 method ,比如__iadd__是+=,当然,也就是后来编译出来的 INPLACE_ADD),当你从语法上玩弄语义的时候(+=, []= 合并成了 x[y]+=z ),就被自己玩了。。
2016-07-25 23:03:36 +08:00
回复了 strahe 创建的主题 Python 关于 Python 的一个问题
并不是一个 Bug ,来看一下 byte code

$ py -3
Python 3.5.1 (v3.5.1:37a07cee5969, Dec 6 2015, 01:54:25) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from dis import dis
>>> dis('''
... a = (1, [1,2,3], 'a')
... a[1] += [4]
... ''')
2 0 LOAD_CONST 0 (1)
3 LOAD_CONST 0 (1)
6 LOAD_CONST 1 (2)
9 LOAD_CONST 2 (3)
12 BUILD_LIST 3
15 LOAD_CONST 3 ('a')
18 BUILD_TUPLE 3
21 STORE_NAME 0 (a)

3 24 LOAD_NAME 0 (a)
27 LOAD_CONST 0 (1)
30 DUP_TOP_TWO
31 BINARY_SUBSCR
32 LOAD_CONST 4 (4)
35 BUILD_LIST 1
38 INPLACE_ADD
39 ROT_THREE
40 STORE_SUBSCR
41 LOAD_CONST 5 (None)
44 RETURN_VALUE

a[1] += [4]实际是两部操作,+= 和 []=

INPLACE_ADD 是 +=
STORE_SUBSCR 是 []=

先发生了+=,然后 []= 报错了。仅此而已。
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   971 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 14ms · UTC 20:22 · PVG 04:22 · LAX 12:22 · JFK 15:22
Developed with CodeLauncher
♥ Do have faith in what you're doing.