Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Chris Angelico Newsgroups: comp.lang.python Subject: Re: How to memory dump an object? Date: Sat, 21 May 2016 15:01:30 +1000 Lines: 13 Message-ID: References: <6c556e26-1350-4fdc-ae9f-7ef198a3ad6b@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de vHZzpDsdKRMWNiDixzsgRwLC+D6Y8x5gayt8HsZQ5WbQ== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'cpython': 0.05; '21,': 0.07; 'tool,': 0.07; 'cc:addr:python-list': 0.09; 'subject:How': 0.09; 'noted,': 0.09; 'statements': 0.09; 'python': 0.10; '2016': 0.16; '2:47': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'segfault': 0.16; 'simple.': 0.16; 'stuff,': 0.16; 'subject:object': 0.16; 'wrote:': 0.16; 'pointer': 0.18; 'together.': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'sat,': 0.23; 'header:In-Reply-To:1': 0.24; 'message- id:@mail.gmail.com': 0.27; 'object,': 0.27; 'idea': 0.28; 'info': 0.34; 'received:google.com': 0.35; 'received:74.125.82': 0.35; 'but': 0.36; 'beginning': 0.36; 'structures': 0.36; 'subject:?': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'thanks': 0.37; 'sources': 0.37; 'data': 0.39; 'easily': 0.39; 'some': 0.40; "you'll": 0.61; 'here.': 0.62; 'combining': 0.66; 'chrisa': 0.84; 'embarrassed': 0.84; 'to:none': 0.91; 'lot,': 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:cc; bh=a1dcpNiwHKWyUtdh+JcrSvmIDiEUQx4wZyAqFAKSjCA=; b=vTzCkprlPJ572F/XxbOku5OwbBvEAa0OH+Z+VdqbaIGnqcLd7uzC2SPNyHkWSZKB+t jFlZjjiP3aNiGAwWOEwhXbThIx9Vne3wicoq+Ztnn31GHTYXmJNjbIpYDgg3bCqfwBG3 /NfCpC6iFQL3RwBTsn4hb8B3CyDKHwcgImWm18FtLFWoXgN8+fWuBL4uh4dIKvbOLWlq bao+zn6trefQQXaFKCwwhUp7YZP06qYHKqjGYMKaMaWw8KRENasMEqNZ2mMAfdIvfh/2 eYZCOTn8RQpYlRsn1l1pGK/ALOP9ow4+0Tv7XNUil7QBoI56LAC0qzqN6oHxgG1nRDOp xqRw== 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=a1dcpNiwHKWyUtdh+JcrSvmIDiEUQx4wZyAqFAKSjCA=; b=ctywNu9ki8rlud197P5ng4CHWSxD4MrM9E8hgqMrQ+ZRxX+mgeNtHoAPPjY8zWL/7V 9cdvIKM7XTUHO7xTyiwpaI7NYpfSMHs4ERjFZ+Rk/Rk4Oub3QmKN46yo5rxBjoeLvK+/ KjLOiC8glB8wVGTiUGIlD/oYa4upR9DhbaLYCcgTiR4gPv6nOk1yC0E5VrdEJUPY7J+C HLAy+kRTGdp86y+oHe9tY1KfsstpTFpvCCOziKXwwFAbv+hIu3NGJmGxaE1ggI8zpCBW aDWlt1QtgTQyEwy16WIzf3Lft0puJos1woN/b6w/bVjzF/+pUX4EgP1WT+ZEcjWbodsr TB3g== X-Gm-Message-State: AOPr4FVOfuuT49kztCbz5+KuSRLURXmGWijhz5H+EST5xN5ruBLC4O8vhwjhxcNJmMJmz/if/XD/G0OMj3Gakw== X-Received: by 10.28.150.211 with SMTP id y202mr6973489wmd.41.1463806890901; Fri, 20 May 2016 22:01:30 -0700 (PDT) In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: X-Mailman-Original-References: <6c556e26-1350-4fdc-ae9f-7ef198a3ad6b@googlegroups.com> Xref: csiph.com comp.lang.python:108895 On Sat, May 21, 2016 at 2:47 PM, wrote: > It's amazing the "tool" is so simple. Actually I feel a little embarrassed that I do know every statements in it but just no idea of combining them together. Thanks a lot, Chris. > It's a pretty complicated tool, actually - but you're using it in a simple way here. If you're curious, you can poke around in the CPython sources to track down the data structures involved - as you noted, the refcount is at the beginning of every object, and after that you'll find some neat info like a pointer to its type. You can even change some of this stuff, but be aware that you can EASILY segfault Python like this :D ChrisA