Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Chris Angelico Newsgroups: comp.lang.python Subject: Re: Encapsulation in Python Date: Tue, 15 Mar 2016 11:58:40 +1100 Lines: 14 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=UTF-8 X-Trace: news.uni-berlin.de q6fVkdt9FFYTEHsZF5C8QQVCWrL5qGITPecmnlkhZ0gg== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'received:209.85.223': 0.03; 'subject:Python': 0.05; 'cc:addr :python-list': 0.09; 'integers': 0.09; 'semantics': 0.09; '2016': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'hashable': 0.16; 'integers,': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'restricting': 0.16; 'sequence.': 0.16; 'wrote:': 0.16; 'tests': 0.18; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'am,': 0.23; 'header:In-Reply-To:1': 0.24; 'message-id:@mail.gmail.com': 0.27; 'restrict': 0.27; 'equality': 0.29; 'types.': 0.29; "i'm": 0.30; '15,': 0.30; 'tue,': 0.34; 'received:google.com': 0.35; 'received:209.85': 0.36; 'subject:: ': 0.37; 'two': 0.37; 'expect': 0.37; 'received:209': 0.38; 'sure': 0.39; 'does': 0.39; 'mar': 0.65; 'gain': 0.82; 'chrisa': 0.84; 'to:none': 0.91; 'subject:skip:E 10': 0.96 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc; bh=YZ5+l1L8qT+Fq2w2bR6hCUlMm2LXY4h6XO4aiGpcm4A=; b=g4/n9hdoEeoW0jATkhPDB/SJmf9D9rkAqQCczSMMSG9ewkmm6hHFIg1uSArcwz6jjt TkbVcjlieMZwlK/D1klN7oQhiUBjadvTKEREmVRYndHpCB+17Gt3+MPrIDXGtJ9U9Ucw Khl51F+7xuEBq5B9U3PpYo9Y9FumreLYgXMV9otMSY0JgajtZPjkyP5LFqJAaK0uwC3R JgOKNHbU7yVjZFIsDXeNIsPuDgBQuOynXGHksL794pMUgzvzHwKAn3wm0BzZd0KCWRIV lEo9SX6OrwRA6UX49bYGpKXq+I79mdrqnQVVq3ja45F/8ZDj2UWzZL+QkdnPZ3bVdS/p 6qGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:cc; bh=YZ5+l1L8qT+Fq2w2bR6hCUlMm2LXY4h6XO4aiGpcm4A=; b=iMBKg3hEu5W97Ki6PJj/jPHrSzAuwli46qaJ0cvUeTT+Wjpm37yBCYOiz5/7Wh0lHH R8FQFVguq1tJt27GhgJKDHr5PgbFmAdvUfblop1XHuPVwvY54N+3x4TRcCh3FtyY6KvT VlDeJznBLpyG0UJE4VRbS8Yv/nuJtJ+IlfDUuzAJPftDziGzsCwF5yb0NmrtGi+6iBlf noBEPD7LejnZv4ah5lrw7/oWKUSmRYPw7P/kPg6ptYMlYQp1svPhI57mCDNOxYk8KGVI AsLWzN98kTZmumiJSjgtnpRhIgRdLHpJsSGB93saiB1E/A76ye8Pt4mYcFJ4mVA2VgSh pM2Q== X-Gm-Message-State: AD7BkJILvayjVrv9FDwDI7Mosr3d6QyB8mj0veSGdnblGU8qKu8HE0G4FbVxVtWGR4TAcWO6yvoxRG7oms9k1Q== X-Received: by 10.107.138.75 with SMTP id m72mr26569879iod.31.1458003520805; Mon, 14 Mar 2016 17:58:40 -0700 (PDT) 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:104892 On Tue, Mar 15, 2016 at 11:54 AM, BartC wrote: >> In Python, there's no reason to restrict 'switch' >> to integers, so I would expect its semantics to be based on either >> equality comparisons or inequality comparisons > > > I use two forms of switch: one for integers only (very fast), and the other > for any other values, which does tests in sequence. I'm not sure what you gain by restricting to integers that you couldn't also gain with other hashable types. Can you elaborate on these optimizations? ChrisA