Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Mark Lawrence Newsgroups: comp.lang.python Subject: Re: Encapsulation in Python Date: Tue, 15 Mar 2016 04:41:30 +0000 Lines: 65 Message-ID: References: <56E17985.7060002@benmezger.nl> <6984dafc-fffd-4d46-a173-421bb5c142d2@googlegroups.com> <4ddc3696-3f71-4598-98a6-929267f51fb9@googlegroups.com> <56e53cd3$0$1586$c3e8da3$5496439d@news.astraweb.com> <1376c684-2e7f-417a-9683-e47789f019fe@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de F3LcXjRvg+GxDk2Ny0JiewWg+9lDime+b6K0thfEhfqA== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'value,': 0.03; 'subject:Python': 0.05; 'cpython': 0.05; 'from:addr:yahoo.co.uk': 0.05; 'rejected': 0.05; 'executed': 0.07; 'expressions': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'bug': 0.10; 'python': 0.10; 'python.': 0.11; 'language,': 0.11; 'index': 0.13; 'missed': 0.15; "(i'm": 0.16; 'deprive': 0.16; 'provision': 0.16; 'really?': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'switch.': 0.16; 'task.': 0.16; 'wrote:': 0.16; 'case.': 0.18; 'tests': 0.18; 'language': 0.19; '>>>': 0.20; 'meant': 0.22; 'lawrence': 0.22; 'code,': 0.23; 'patch': 0.24; 'header:In-Reply- To:1': 0.24; 'testing': 0.25; "i've": 0.25; 'header:User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'switch': 0.27; 'least': 0.27; 'sequence': 0.27; 'function': 0.28; 'actual': 0.28; 'looks': 0.29; 'pep': 0.29; "i'm": 0.30; 'too.': 0.30; 'code': 0.30; 'branch': 0.30; 'another': 0.32; 'language.': 0.32; 'statement': 0.32; 'getting': 0.33; 'jump': 0.33; 'running': 0.34; 'done': 0.35; 'clear': 0.35; 'label': 0.35; 'something': 0.35; 'but': 0.36; 'should': 0.36; 'needed': 0.36; 'there': 0.36; "wasn't": 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'agree': 0.37; 'received:org': 0.37; 'anything': 0.38; 'building': 0.38; 'test': 0.39; 'sure': 0.39; 'rather': 0.39; 'to:addr:python.org': 0.40; 'where': 0.40; 'mark': 0.40; 'some': 0.40; 'easy': 0.60; 'your': 0.60; 'provide': 0.61; 'show': 0.62; 'total': 0.62; 'yes': 0.62; 'details': 0.62; 'charset:windows-1252': 0.62; 'above,': 0.63; 'strange': 0.63; 'more': 0.63; 'profile': 0.63; 'interest': 0.64; 'within': 0.64; 'our': 0.64; 'you.': 0.64; 'respect': 0.65; 'results.': 0.67; 'yourself': 0.73; 'calls,': 0.84; 'of?': 0.84; 'pythonistas,': 0.84; 'terrible': 0.84; 'yourself...': 0.84; 'refuse': 0.93; 'subject:skip:E 10': 0.96 X-Injected-Via-Gmane: http://gmane.org/ X-Gmane-NNTP-Posting-Host: 80.234.129.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:104915 On 15/03/2016 01:10, BartC wrote: > On 15/03/2016 00:28, Mark Lawrence wrote: >> On 14/03/2016 23:56, BartC wrote: > >>> Anything so terrible about that that Python needs to keep well clear of >>> or that you think its users should be deprived of? >> >> Yes, it is not even valid Python. Switch has been rejected via at least >> one PEP and from what I see it adds nothing to the language, so let's >> deprive it from people who clearly don't need it in the first place. > > Every time you need to test X against more than one other value, then > you have a potential use for switch. > > But yes you can do without switch if you have too. Same for many features. > >> I am only rude to people such as yourself who refuse to provide code, in >> fact anything, to support your case. Your "benchmark" for the switch >> was yet another laughable farce, which only tested the function calls, >> building tuples, running loops, there was nothing to test with respect >> to the actual switch which was meant to be tested. So just in case you >> missed it above, where is the profile for this test? > > I've shown the task. I'm sure you can also do some tests and show us > some results. > >>> I agree with you. But once you've got the language right, then there's >>> no harm looking at performance. A switch statement like the above can be >>> executed in a single byte-code. >>> >> >> Really? Then please show us all just how it can be done via a patch to >> the cPython code on the bug tracker. > > The one-byte-code switch works when all case expressions are known at > compile-time. It makes use of a jump-table within the byte-code. > > The total sequence will be more than one byte-code, typically: > > LOAD_FAST The index > SWITCH Jump to the right label > .... > L5: One of multiple labels > ... Deal with the code in this branch > JUMP_ABSOLUTE Break out of the switch > > ... Provision is needed for the jump-table > > But only one is needed for testing and dispatch. Now I've sketched it > out, perhaps you can fill in the details for yourself... (I'm not > getting involved in CPython development.) > > I have no interest at this level. If I were I might as well have stuck with C in the first place. I do find it rather strange that something so simple wasn't approved when the PEP(s) were discussed as it looks so easy to implement. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence