Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!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; 'subject:Python': 0.05; 'compiler': 0.05; 'memory.': 0.05; 'run-time': 0.05; 'bits': 0.07; 'layers': 0.07; 'linker': 0.07; 'x86': 0.07; '16-bit': 0.09; 'corresponds': 0.09; 'referenced': 0.09; 'aug': 0.13; 'stack': 0.15; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'hard-code': 0.16; 'hrm.': 0.16; 'jumps': 0.16; 'locations.': 0.16; 'offsets': 0.16; 'roy': 0.16; 'segment': 0.16; 'subject:Objects': 0.16; 'why,': 0.16; 'mon,': 0.16; 'wrote:': 0.17; 'compilation': 0.17; '(or': 0.18; 'variable': 0.20; 'received:209.85.214.174': 0.21; 'logical': 0.22; 'seems': 0.23; 'header:In-Reply-To:1': 0.25; 'am,': 0.27; 'compiled': 0.27; 'change,': 0.27; 'in.': 0.27; 'message-id:@mail.gmail.com': 0.27; "doesn't": 0.28; 'fixed': 0.28; '>>>>': 0.29; "d'aprano": 0.29; 'steven': 0.29; 'probably': 0.29; "i'm": 0.29; 'maybe': 0.29; "we're": 0.30; 'knows': 0.30; 'that.': 0.30; 'relative': 0.30; 'code': 0.31; 'good.': 0.32; 'could': 0.32; 'cases,': 0.33; 'programming,': 0.33; 'to:addr:python-list': 0.33; 'likely': 0.33; 'that,': 0.34; 'received:google.com': 0.34; 'whatever': 0.35; 'locations': 0.35; 'mapping': 0.35; 'too.': 0.35; 'received:209.85': 0.35; 'something': 0.35; 'there': 0.35; 'tool': 0.36; 'but': 0.36; 'loaded': 0.36; 'should': 0.36; 'does': 0.37; 'uses': 0.37; 'received:209': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'several': 0.39; 'to:addr:python.org': 0.39; 'received:209.85.214': 0.39; 'header:Received:5': 0.40; 'think': 0.40; 'your': 0.60; 'most': 0.61; 'first': 0.61; 'back': 0.62; 'ever': 0.63; 'skip:n 10': 0.63; 'more': 0.63; 'within': 0.64; 'fun': 0.64; 'smith': 0.71; 'article': 0.78; 'fascinating': 0.91 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 :content-type; bh=oCH9o+QIn5/tAIvR+WWMkhcMfmVk/LbBSGcFG15IiJQ=; b=GsOfi3JsDWA+9PM57fL/DIBDTxB8T4jEOX1kRssIJSNb6AAmF9xx59+Vzy+0eOQBcV Zm1q9thGF1/I6AXgL/xOjQYUfQcMN+0PKhNPbCfL4JUuVdhJnY1WJKROFunOm+6PkEBI iPRn5IVGVUUKKrT5HKA10PA1E9Bq/xfO9iVhth83QaAp3OPZ3egqX3Gfmjla0th0cbmz m2kni+QvtaJSNnT3sreKZf4O0qE9UtIEEtIX7mcSc2AKD5RRtUubwihP9uqlESZs/Rm2 5OIJoq59XDMwrcQT3RUSBrzbLp+u0LOXZOvgk5PVXg7iMTuiYAqym33kYPHEembB4sFa nyhQ== MIME-Version: 1.0 In-Reply-To: References: <18409992-1e28-4721-8e64-60c69668da4e@googlegroups.com> <87d32i1ntc.fsf@benfinney.id.au> <7df4c317-7ad8-4158-900a-b52f19c3caf2@k9g2000pbr.googlegroups.com> <503750b9$0$6574$c3e8da3$5496439d@news.astraweb.com> <503a2804$0$6574$c3e8da3$5496439d@news.astraweb.com> Date: Mon, 27 Aug 2012 00:14:11 +1000 Subject: Re: Objects in Python From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 35 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1345990454 news.xs4all.nl 6894 [2001:888:2000:d::a6]:35099 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:27926 On Mon, Aug 27, 2012 at 12:02 AM, Roy Smith wrote: > In article <503a2804$0$6574$c3e8da3$5496439d@news.astraweb.com>, > Steven D'Aprano wrote: > >>>> The mapping of name:address is part of the *compilation* process -- >>>> the compiler knows that variable 'x' corresponds to location >>>> 12345678 > > Just to pick a nit, the compiler probably doesn't know that, but the > linker does (or maybe even the run-time loader). However, we can think > of all of those as just part of the compilation tool chain, and then > we're good. Hrm. Back when I first started C programming, it was MS-DOS 16-bit work - segmented addressing (one of the most fascinating insanities ever to be perpetrated on unsuspecting consumers - why, oh why, if you want 20-bit addressing, should you invent a system that uses 32 bits of data in such a non-expandable way?). My program would be loaded into whatever segment the loader chose, but offsets within that could be compiled in. With modern x86 systems there are several more layers of complication, but in many cases, you can still hard-code offsets within a logical segment of memory. Set CS to your one code segment and do your jumps and calls at fixed locations. Set [DEFG]S to your single data segment and all your data can be at fixed locations too. (Obviously your stack is referenced relative to SP/BP.) I'm not familiar with other architectures, but it seems likely that there's something similar. The segment / base location may change, but variable 'x' still corresponds to 12345678 within that. Nits can be fun to pick :) ChrisA