Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!us.feeder.erje.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!news-1.dfn.de!news.dfn.de!news.informatik.hu-berlin.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Gregory Ewing Newsgroups: comp.lang.python Subject: Re: Slices time complexity Date: Tue, 19 May 2015 23:00:28 +1200 Lines: 29 Message-ID: References: <9ceklad15llnv3npejq9iuh91soci8aeqo@4ax.com> <7ea01590-a559-46e5-abf5-29622e39aae7@googlegroups.com> <555ac697$0$12910$c3e8da3$5496439d@news.astraweb.com> <862693ca-42cf-4f5b-ac12-133e43e7606b@googlegroups.com> <878uclf3bt.fsf@elektro.pacujo.net> <555af171$0$12995$c3e8da3$5496439d@news.astraweb.com> <874mn9ezaw.fsf@elektro.pacujo.net> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net 7GusNte0XqfzK8rWksQoBQzUJSwL+6/kNQOi8Rvml1rGBNMUGT Cancel-Lock: sha1:uLReVJTskpC/efNFdRNtQbGzr0Y= User-Agent: Mozilla Thunderbird 1.0.5 (Macintosh/20050711) X-Accept-Language: en-us, en In-Reply-To: Xref: csiph.com comp.lang.python:90839 Chris Angelico wrote: > 1) Pointer arithmetic simply doesn't exist in Python. Arrays/lists are > not just pointers to their first elements, and subscripting is most > definitely NOT "add to pointer and dereference". > 2) In fact, dereferencing as a whole isn't really a 'thing' either. At > best, it happens automatically. > 3) References actually mean something. Copying a pointer doesn't. > Whether the Python you're using is refcounted (CPython) or > mark-and-sweep (uPy, I think) or some other model, an additional > reference to the same object will prevent it from being disposed of, > which isn't the case in C. > 4) A pointer is itself a value. You can pass a > pointer-to-local-variable to another function and have that function > change a local variable. > 5) Furthermore, since a pointer is a value, you can have pointers to > pointers, etc. Doesn't make any sense in Python. FWIW, most of those things are peculiar to C, and are not necessarily shared even with other languages that have explicit pointers. In Pascal, for example, there is no pointer arithmetic, and (at least not without nonstandard extension) you can't make a pointer point into the middle of a stack frame or array or record, etc. (You *can* have a pointer to a pointer, but only by heap-allocating a memory block containing a single pointer, which is not useful very often). -- Greg