Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.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.023 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'dict': 0.09; 'sure,': 0.09; 'cc:addr:python-list': 0.10; 'declaration': 0.16; 'functions.)': 0.16; 'oct': 0.16; 'wrote:': 0.17; 'pointer': 0.17; 'thu,': 0.17; 'cc:2**0': 0.23; '(you': 0.23; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply- To:1': 0.25; '(e.g.,': 0.27; 'message-id:@mail.gmail.com': 0.27; 'source': 0.29; 'probably': 0.29; 'usually': 0.30; 'daniel': 0.30; 'received:209.85.215.46': 0.30; 'received:google.com': 0.34; 'thanks': 0.34; 'list': 0.35; 'pm,': 0.35; 'received:209.85': 0.35; 'method': 0.36; 'received:209': 0.37; 'subject:: ': 0.38; 'skip:o 20': 0.38; 'called': 0.39; 'header:Received:5': 0.40; 'subject:. ': 0.66; 'pytypeobject': 0.84; 'urban': 0.95 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:to :cc:content-type; bh=MPCr/cUk+KWVWH8MfcacZEcT32TgbPO5Gky14Em1rbo=; b=1JvGuxgZ73ifl3j7MKCBgDREhxl1Z7DhDmlzmHw05FY9sI7fGDRZ0yq7ZiVzNk63bv ZbEFTbbPtFvAG3h4ZbRjZJKSvBGP4lj9W7PeQ9VEmdaXRi6ogRwHL0YTt94jCzFgjftr O/AUXFbp6NfEW8sdjyHjUrFoRirFL5W1/Rb9ZfbZk91ktOzYD6aHQU1zBXTasXeLDVsk hlaV77R/uE/GSYczD0yGrWerzVqI+OYSwwbcTZ5UvzXNm14d3Pa/ivL1u1Gp111wdotL I+vuQRjM29+PSyGjDUM4Ux/ItBq6Ra7HCkU2M69lEblQXsXzJsYMnSMf8TKpza+SuqNQ sXeA== MIME-Version: 1.0 In-Reply-To: References: <50803B2C.6010900@gmail.com> <50804DA8.80708@gmail.com> Date: Thu, 18 Oct 2012 15:25:13 -0700 Subject: Re: len() on mutables vs. immutables From: Demian Brecht To: Daniel Urban Content-Type: text/plain; charset=ISO-8859-1 Cc: python-list@python.org 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: 11 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1350599115 news.xs4all.nl 6896 [2001:888:2000:d::a6]:49187 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:31689 On Thu, Oct 18, 2012 at 12:43 PM, Daniel Urban wrote: > The source is usually in Objects/*object.c (e.g., the source for list > is in Objects/listobject.c, dict is in dictobject.c and so on). The > implementation of __len__ is usually in a method called > whatever_length (e.g., dict.__len__ is called dict_length). To be > sure, you can check the PyTypeObject declaration for the type. > Probably the tp_as_sequence or tp_as_mapping field contains the > pointer to __len__ (sq_length or mp_length respectively). (You can > also search for "lenfunc", which is the type of such functions.) Many thanks for the details.