Path: csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'received:134': 0.05; 'concurrently': 0.07; 'generators': 0.09; 'runtime': 0.09; 'thrown': 0.09; 'underlying': 0.09; 'thread': 0.10; 'python': 0.10; 'exception': 0.13; 'stack': 0.13; 'value.': 0.15; 'cause.': 0.16; 'crashed': 0.16; 'crashes': 0.16; 'generator.': 0.16; 'received:ac.be': 0.16; 'thread.': 0.16; 'threads': 0.16; 'trace.': 0.16; 'zero,': 0.16; 'wrote:': 0.16; '2015': 0.20; 'affected': 0.22; 'suppose': 0.22; 'trace': 0.22; 'header:In- Reply-To:1': 0.24; 'header:User-Agent:1': 0.26; 'chris': 0.26; 'fri,': 0.27; 'yield': 0.27; 'record': 0.29; 'exclude': 0.29; 'itself,': 0.29; 'sure,': 0.29; 'subject:/': 0.30; 'received:be': 0.30; "can't": 0.32; 'jump': 0.33; 'case,': 0.34; 'next': 0.35; 'could': 0.35; "isn't": 0.35; 'but': 0.36; 'should': 0.36; 'there': 0.36; 'to:addr:python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'really': 0.37; 'expect': 0.37; 'one,': 0.37; 'why': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.40; 'still': 0.40; 'some': 0.40; 'your': 0.60; 'back': 0.62; 'matter': 0.63; 'different': 0.63; 'information': 0.63; 'records': 0.70; 'jul': 0.72; 'divide': 0.84; 'pardon': 0.84; 'by.': 0.91 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtcHAG36qFWGuA9G/2dsb2JhbABbhCwkgyPAMgKCGAEBAQEBAYUuAQEBAwEjVQYLCxgCAgUWCwICCQMCAQIBRRMGAgKIIgi6G5FIhGYBAQgCIIEiiiqFDRaCUoFDAQSMN4gVjB+BQ4Z4jGeDYSZjgxttAYJKAQEB Date: Fri, 17 Jul 2015 14:54:14 +0200 From: Antoon Pardon User-Agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Icedove/31.7.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Possibly Pythonic Tail Call Optimization (TCO/TRE) References: <87d1zunctp.fsf@elektro.pacujo.net> <87k2u2eu67.fsf@elektro.pacujo.net> <55A51662.4090007@rece.vub.ac.be> <55A75DE0.1070101@rece.vub.ac.be> <55A7B80B.6090905@rece.vub.ac.be> <55A7C094.7060604@rece.vub.ac.be> <55A8DD75.5000403@rece.vub.ac.be> <55A8EA7D.2040005@rece.vub.ac.be> In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ 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: 39 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1437137656 news.xs4all.nl 2954 [2001:888:2000:d::a6]:33640 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:94010 On 07/17/2015 01:49 PM, Chris Angelico wrote: > On Fri, Jul 17, 2015 at 9:43 PM, Antoon Pardon > wrote: > > >> Sure, but in this case, the generator is still active. The Runtime >> would be able to jump to and somehow activates it's stack record >> for the next value. So why would we expect it to be impossible to >> include this trace back record in a stack trace? > Python could also give you stack traces for any other threads that are > concurrently running, on the off-chance that one of them affected it. > But the only influence the generator has on the loop is to yield a > value or signal termination; if an exception is thrown in the loop > itself, the local name 'stuff' should have all the information about > that cause. But the local name 'stuff' may only have the information for the immediate cause. The underlying cause may be available in the generator. Suppose you have a generator that should only generate positive numbers that you use to divide some other number by. Your loop crashes because of a DivideByZeroError Sure the local name shows the dividor to be zero, but you have no information on why your generator produced a zero, but there may be a clue in the trace back record of the generator. > Python isn't a mind-reader, no matter how much it may look > like one, and it can't know that this function's return value should > be shown as part of a completely different function's stack trace. It is not a matter of mindreading. And it is not a completely different functions stack trace. It is the trace back record of a generator that is used by the process/thread that crashed. And AFAIK an active generator belongs to one specific thread. You can't have it yield a value to a different thread and you can't send it a value from an other thread. So I really see no reason to exclude the trace back records of active generators from a stack trace of a crashed thread. -- Antoon Pardon