Path: csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsfeed.xs4all.nl!newsfeed6.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; 'compiler': 0.05; 'debugging': 0.05; '"c"': 0.07; 'parsing': 0.07; '*is*': 0.09; 'array.': 0.09; 'called.': 0.09; 'indicates': 0.09; 'pointer;': 0.09; 'slices': 0.09; 'storage.': 0.09; 'subject:()': 0.09; 'tuple': 0.09; 'undocumented': 0.09; ':-)': 0.13; '4:39': 0.16; 'length,': 0.16; 'oct': 0.16; 'pointers,': 0.16; 'subject:array': 0.16; 'syntax,': 0.16; 'mon,': 0.16; 'wrote:': 0.17; 'copied': 0.17; 'pieces': 0.17; 'pointer': 0.17; 'code,': 0.18; 'all,': 0.21; 'latter': 0.22; 'struct': 0.22; 'defined': 0.22; 'elements': 0.23; 'somewhere': 0.24; 'header:In-Reply-To:1': 0.25; 'appear': 0.26; 'andrew': 0.27; 'message-id:@mail.gmail.com': 0.27; 'pointer.': 0.29; 'tail': 0.29; 'objects': 0.29; 'words': 0.29; 'received:209.85.215.46': 0.30; 'function': 0.30; 'not.': 0.32; 'says': 0.33; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'list': 0.35; 'generic': 0.35; 'stores': 0.35; 'pm,': 0.35; 'received:209.85': 0.35; 'there': 0.35; 'but': 0.36; 'does': 0.37; 'two': 0.37; 'why': 0.37; 'passed': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'comment': 0.38; 'object': 0.38; 'things': 0.38; 'to:addr:python.org': 0.39; 'called': 0.39; 'header:Received:5': 0.40; 'your': 0.60; 'information': 0.63; 'making': 0.64; 'struct.': 0.84; 'to:name:python': 0.84; 'info,': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=cwODHbkVeFo5NTW0UcUpgPYOC/c66rIQkwujU0hWUwc=; b=LbCEQL9EZLPmSDcsoLZ7SatxzIhUCVpQ1wedBrdeBYUvGb7cfi8euxF1PzjNEwFbDP hhqNbug//dQ2pkMglx6Po0Lc+iZuuu84uDtgLddU13C+/CJqlzEMNs9zmhDCQ6f3eoD+ VhXhDmQxEU8GBp8OS92htUO+d8lf9MJ4Y7Dfy8gP+3xXlwONzx9qm5M6TyeNNxiv+Akk EL98T+wP16VkGvnesuwLioK8VquMSiiWkXqbPRIJn3dKHpyfbVZWGMz8DqLsBKqUrzLj 5j5VKoQXzMLpWhyXp8G/zkhecXE/D2S2Ldopnea9pooFaXZ6YmvBK9AEbRkq+ZZpthAM ZX1Q== MIME-Version: 1.0 In-Reply-To: <508F05AE.50607@r3dsolutions.com> References: <6998a955-7b34-4f4f-b8d6-62d1028f7561@googlegroups.com> <4c024364-84df-403b-8b9e-4a4c8f06121c@googlegroups.com> <508e6649$0$29967$c3e8da3$5496439d@news.astraweb.com> <508E1BC9.3000308@r3dsolutions.com> <508EC428.5080808@r3dsolutions.com> <508F05AE.50607@r3dsolutions.com> From: Ian Kelly Date: Tue, 30 Oct 2012 00:51:19 -0600 Subject: Re: Negative array indicies and slice() To: Python Content-Type: text/plain; charset=ISO-8859-1 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: 32 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1351579918 news.xs4all.nl 6953 [2001:888:2000:d::a6]:39801 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:32469 On Mon, Oct 29, 2012 at 4:39 PM, Andrew Robinson wrote: > In addition to those items you mention, of which the reference count is not > even *inside* the struct -- there is additional debugging information not > mentioned. Built in objects contain a "line number", a "column number", and > a "context" pointer. These each require a full word of storage. > > Also, built in types appear to have a "kind" field which indicates the > object "type" but is not a pointer. That suggests two "object" type > indicators, a generic pointer (probably pointing to "builtin"? somewhere > outside the struct) and a specific one (an enum) inside the "C" struct. > > Inside the tuple struct, I count 4 undocumented words of information. > Over all, there is a length, the list of pointers, a "kind", "line", "col" > and "context"; making 6 pieces in total. > > Although your comment says the head pointer is not required; I found in > 3.3.0 that it is a true head pointer; The Tuple() function on line 2069 of > Python-ast.c, (3.3 version) -- is passed in a pointer called *elts. That > pointer is copied into the Tuple struct. As above, you're looking at the compiler code, which is why you're finding things like "line" and "column". The tuple struct is defined in tupleobject.h and stores tuple elements in a tail array. > How ironic, slices don't have debugging info, that's the main reason they > are smaller. > When I do slice(3,0,2), suprisingly "Slice()" is NOT called. > But when I do a[1:2:3] it *IS* called. Because compiling the latter involves parsing slicing syntax, and compiling the former does not. :-)