Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'python,': 0.02; 'cpython': 0.05; 'subject:Python': 0.06; 'cache': 0.07; '__init__': 0.09; 'differently.': 0.09; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'instances.': 0.09; 'message-id:@stoneleaf.us': 0.09; 'python:': 0.09; '~ethan~': 0.09; 'python': 0.11; 'def': 0.12; 'a()': 0.16; 'behave': 0.16; 'created.': 0.16; 'dict': 0.16; 'filename:fname piece:signature': 0.16; 'sure.': 0.16; 'thankfully,': 0.16; 'wrote:': 0.18; 'stack': 0.19; '>>>': 0.22; 'preferred': 0.22; 'saying': 0.22; 'print': 0.22; 'header:User-Agent:1': 0.23; 'header:In-Reply-To:1': 0.27; "i'm": 0.30; 'code': 0.31; 'class': 0.32; 'quite': 0.32; 'subject: (': 0.35; 'no,': 0.35; 'but': 0.35; 'there': 0.35; 'instances': 0.36; 'doing': 0.36; 'should': 0.36; 'changing': 0.37; 'implement': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'that,': 0.38; 'to:addr:python.org': 0.39; 'even': 0.60; 'received:173': 0.61; 'simply': 0.61; 'subject:! ': 0.74; 'awesome,': 0.84; 'optimisation': 0.84; 'subject:!)': 0.84 Date: Tue, 03 Feb 2015 15:55:14 -0800 From: Ethan Furman User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: dunder-docs (was Python is DOOMED! Again!) References: <54c07d04$0$13012$c3e8da3$5496439d@news.astraweb.com> <54cd9a7a$0$12984$c3e8da3$5496439d@news.astraweb.com> <54ce526a$0$13012$c3e8da3$5496439d@news.astraweb.com> <54cf242d$0$12991$c3e8da3$5496439d@news.astraweb.com> <54cf6836$0$12996$c3e8da3$5496439d@news.astraweb.com> <54cf849d$0$13005$c3e8da3$5496439d@news.astraweb.com> <87zj8vgtzk.fsf@elektro.pacujo.net> <87vbjjgrpj.fsf@elektro.pacujo.net> <87egq6adm1.fsf@elektro.pacujo.net> <878ugea7wh.fsf@elektro.pacujo.net> In-Reply-To: <878ugea7wh.fsf@elektro.pacujo.net> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="2tq7wNrbINJBNJnorNPG6G31kLxJLamQl" X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 75 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1423007720 news.xs4all.nl 2912 [2001:888:2000:d::a6]:46836 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:85187 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --2tq7wNrbINJBNJnorNPG6G31kLxJLamQl Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 02/03/2015 03:32 PM, Marko Rauhamaa wrote: > Gregory Ewing : >=20 >> You seem to be suggesting an optimisation that pre-creates bound >> methods when the instance is created. Keeping a cache of bound methods= >> would achieve the same thing without changing the semantics. I think >> CPython might already be doing that, but I'm not sure. >=20 > No, I'm saying Python should behave differently. >=20 > Python: >=20 > >>> class A: > ... def f(self): > ... print("f") > ... def g(self): > ... print("g") > ...=20 > >>> a =3D A() > >>> a.__class__.f =3D a.__class__.g > >>> a.f() > g > =20 > In my preferred semantics, a.f() would print >=20 > >>> a.f() > f That is, as you acknowledge, not Python. Thankfully, it will also never be Python. However, because Python is so awesome, you can twist your own code to beh= ave that way, to a point: simply have your __init__ ( or __new__) populate the instance dict with all non-dunder met= hods. Or even better, implement your own proto(mumble) type stack in Python, so= there is some warning that your instances don't behave quite like normal Python instances. -- ~Ethan~ --2tq7wNrbINJBNJnorNPG6G31kLxJLamQl Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iQIcBAEBAgAGBQJU0V/kAAoJENZ7D1rrH75NbToP/Rlwq6bchRSIx3gFiWSk4T0w Vgq0BKsHeWlQdBGkQXFI6kpNMBYu/GlCmjKfYeSKKu7kUcmocZOWamI3N4YK+jEw Cz00VxO+ZJw44Xh646UZa341psK1hU2KacRiEyET7IhuT3HfTi7MXwlQ5TuV0p9i +KgdcFsuLsvKh6IbENWM0BxbcnRSOejcY7XjmCgA8y4gGRz6E+tRwkyNNv+Omn7g 8krs1TdZE1xjjWrkgIV/99tIH0LQpCe2efcJyY4QN8SjGRDgRXSOa6+xmv3PqQ0g Ittgc0NvzvKfphdr1F6wzRszL4Fph55E1HRZQW2JUAzp65ZrJRrdcpz9OmTMO5A0 dIBej5NPF2ygO9qTda0FdI80IkHyhwrb2s7R0ufe3tEUrRW24/WRO+dmyyPItnd2 D3slLjGrFAyE7mHpZFQjrjKrZ9hU6O5vRtV9mDKskMCgNDAv2qV8KWqBa7K+lsgQ X9RP0Y/vhIFkRUWMMUKY4MBei0F0upDI38qB+ShJQ2KLKWLtNEdhEVqDqobnLU0c xQyhM3AmgTDQOXJQjUB3MT6XJ08t2JUX3eFlJjB5UEWCrHVYLVwe+POHheFPrNeM BDXv7D7B00+ZfYcZOWB3j4fXQxez9lm3aG3dFanNipJ+YxDw41X54vGoDyZeHJaO xd3lTLKi1FUrXSKO3reD =VKq0 -----END PGP SIGNATURE----- --2tq7wNrbINJBNJnorNPG6G31kLxJLamQl--