Path: csiph.com!usenet.pasdenom.info!news.etla.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.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.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'cpython': 0.05; 'tree': 0.05; 'none,': 0.07; 'suppose': 0.07; 'correspond': 0.09; 'pep': 0.09; 'ellipsis': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'marshalled': 0.16; 'exception': 0.16; 'seems': 0.21; 'handles': 0.22; 'to:name:python-list@python.org': 0.22; 'byte': 0.24; 'source': 0.25; 'handling': 0.26; 'this:': 0.26; 'is?': 0.30; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; 'class': 0.32; 'url:python': 0.33; 'but': 0.35; 'received:google.com': 0.35; 'subject:?': 0.36; 'url:org': 0.36; 'should': 0.36; 'url:library': 0.38; 'to:addr:python-list': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'skip:u 10': 0.60; 'url:5': 0.61; 'url:3': 0.61; 'unusual': 0.74; 'special': 0.74; 'subject:skip:S 10': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=+acWcJYavL6/kkVlRawhBsirea3wNrtZ+NaydB7HyLE=; b=B90XRFjQN6rVrCbn+JxkxNvq1ttKHk868PjdG1iAxINdE9Bfa+K4XLQ4rI95We/5V/ 5U8uqzZRHrwQhYxpXhymCDpp9GKOmTFsMG0HzbaIIJ0uCZjYvZH0+D46lRga13rqy3HC p9L00bZ0MmoO4mPoQKePHur2pjVo0Lck21Di65IwknfO2Aa3VzTyQSr12NZGptPo6pXv 6eOfhy3yed3p5ADHQJ4eFEKTYH/1Q0cq6RMxkMVjEn8OkSRMt5P39SMpkx0MiV5rWp3q jiaTptjhhwaguzpVzwmV1KfQCODuAeqkGy00iagG8WeR4muAidPLkDJzpF+nzU7fa++N jJfA== MIME-Version: 1.0 X-Received: by 10.50.136.134 with SMTP id qa6mr48727igb.2.1416448345346; Wed, 19 Nov 2014 17:52:25 -0800 (PST) Date: Thu, 20 Nov 2014 12:52:25 +1100 Subject: Is StopIteration a singleton? From: Chris Angelico To: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 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: 18 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1416448354 news.xs4all.nl 2907 [2001:888:2000:d::a6]:45337 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:81047 While poking about the cpython source tree with reference to PEP 479, I came across this: https://docs.python.org/3.5/library/marshal.html """singletons None, Ellipsis and StopIteration can also be marshalled and unmarshalled.""" StopIteration is a type. I suppose it's still kinda true that there's only one StopIteration class (otherwise exception handling would get very messy), but it seems unusual that this one particular exception class should be special-cased. (And yes, the code does correspond - marshal.c:293 handles StopIteration with its own byte code.) Why is StopIteration marshallable but no other exception is? Or, if they are marshallable, why does this one get special handling? ChrisA