Re: About the implementation of del in Python 3

2017-07-07 Thread Gregory Ewing
Random832 wrote: What's not abstract is that if an object has address X and is N bytes long, those bytes (and any larger subobjects) occupy a contiguous range of addresses between X and X+(N-1). If you're talking about Python objects, that's not necessarily true -- there's no requirement that a

Re: About the implementation of del in Python 3

2017-07-07 Thread Ian Kelly
On Fri, Jul 7, 2017 at 8:41 AM, Nathan Ernst wrote: > Looks like single expression statements are handled a bit differently than > multiple expression statements: > > Python 3.5.2 (default, Nov 17 2016, 17:05:23) > [GCC 5.4.0 20160609] on linux > Type "help", "copyright", "credits" or "license" fo

Re: About the implementation of del in Python 3

2017-07-07 Thread Ian Kelly
On Thu, Jul 6, 2017 at 12:56 PM, Nathan Ernst wrote: > In Python, "==" is not a reference equality operator (and I hate Java for > their misuse of the operator), so I absolutely disagree with using the Java > description to describe Python's "==" operator, primarily because, well, > it's wrong. Si

Re: About the implementation of del in Python 3

2017-07-07 Thread Random832
On Fri, Jul 7, 2017, at 10:41, Nathan Ernst wrote: > Looks like single expression statements are handled a bit differently > than > multiple expression statements: > > Python 3.5.2 (default, Nov 17 2016, 17:05:23) > [GCC 5.4.0 20160609] on linux > Type "help", "copyright", "credits" or "license" f

Re: About the implementation of del in Python 3

2017-07-07 Thread Random832
On Fri, Jul 7, 2017, at 04:12, Gregory Ewing wrote: > Only if you interpret the word "address" very narrowly. > > By the way, even the low-level notion of "address" that C > programs deal with is, on most modern hardware, a *virtual* > address that goes through a level of translation before it > i

Re: About the implementation of del in Python 3

2017-07-07 Thread Nathan Ernst
Looks like single expression statements are handled a bit differently than multiple expression statements: Python 3.5.2 (default, Nov 17 2016, 17:05:23) [GCC 5.4.0 20160609] on linux Type "help", "copyright", "credits" or "license" for more information. >>> n = 4000; m = 4000; n is m True >>> n =

Re: About the implementation of del in Python 3

2017-07-07 Thread Chris Angelico
On Fri, Jul 7, 2017 at 9:48 PM, Marko Rauhamaa wrote: > Chris Angelico : > >> On Fri, Jul 7, 2017 at 7:15 PM, Marko Rauhamaa wrote: >>> You can only define the semantics of Python (in this case) by >>> providing an *arbitrary* mapping to an imaginary abstract machine. >>> There's no way to define

Re: About the implementation of del in Python 3

2017-07-07 Thread Marko Rauhamaa
Chris Angelico : > On Fri, Jul 7, 2017 at 7:15 PM, Marko Rauhamaa wrote: >> You can only define the semantics of Python (in this case) by >> providing an *arbitrary* mapping to an imaginary abstract machine. >> There's no way to define the objective abstraction. > > So aside from an artificial se

Re: About the implementation of del in Python 3

2017-07-07 Thread Chris Angelico
On Fri, Jul 7, 2017 at 7:15 PM, Marko Rauhamaa wrote: > Chris Angelico : > >> On Fri, Jul 7, 2017 at 6:43 PM, Marko Rauhamaa wrote: >>> Python's integer object 0 might be equated with the (mathematical) >>> natural number 18974387634. Python code would have no way of >>> introspecting that natura

Re: About the implementation of del in Python 3

2017-07-07 Thread Marko Rauhamaa
Chris Angelico : > On Fri, Jul 7, 2017 at 6:43 PM, Marko Rauhamaa wrote: >> Python's integer object 0 might be equated with the (mathematical) >> natural number 18974387634. Python code would have no way of >> introspecting that natural number. >> >> The execution model would determine what prope

Re: About the implementation of del in Python 3

2017-07-07 Thread Chris Angelico
On Fri, Jul 7, 2017 at 6:58 PM, Marko Rauhamaa wrote: > Steve D'Aprano : > >> But the Python virtual machine doesn't require objects to have an >> address at all. > > That's an interesting question. Is it possible to define formal > semantics for Python without the notion of an address (under some

Re: About the implementation of del in Python 3

2017-07-07 Thread Marko Rauhamaa
Steve D'Aprano : > But the Python virtual machine doesn't require objects to have an > address at all. That's an interesting question. Is it possible to define formal semantics for Python without the notion of an address (under some name)? Ultimately it seems necessary to have an enumerable set (

Re: About the implementation of del in Python 3

2017-07-07 Thread Marko Rauhamaa
Steve D'Aprano : > On Fri, 7 Jul 2017 05:45 pm, Chris Angelico wrote: > >> On Fri, Jul 7, 2017 at 4:43 PM, Steve D'Aprano >> wrote: >>> On Fri, 7 Jul 2017 01:41 am, Marko Rauhamaa wrote: In Second-Order Logic, you can define identity directly: ∀x ∀y x = y ↔ ∀P (P(x) ↔ P(y)) >>>

Re: About the implementation of del in Python 3

2017-07-07 Thread Chris Angelico
On Fri, Jul 7, 2017 at 6:43 PM, Marko Rauhamaa wrote: > Steve D'Aprano : > >> On Fri, 7 Jul 2017 07:10 am, Marko Rauhamaa wrote: >> >>> I believe identity can be defined much better, in numerous isomorphic >>> ways in fact. >>> >>> For example, we could equate each object with a sequence number >>

Re: About the implementation of del in Python 3

2017-07-07 Thread Steve D'Aprano
On Fri, 7 Jul 2017 06:12 pm, Gregory Ewing wrote: > Steve D'Aprano wrote: >> That implies that it is impossible to implement Scheme: >> >> - using a programming language where variables and objects may move during >> their lifetime; >> >> - or using a computing device without conventional memory

Re: About the implementation of del in Python 3

2017-07-07 Thread Marko Rauhamaa
Steve D'Aprano : > On Fri, 7 Jul 2017 07:10 am, Marko Rauhamaa wrote: > >> I believe identity can be defined much better, in numerous isomorphic >> ways in fact. >> >> For example, we could equate each object with a sequence number >> (unrelated with its id()). You can define that the "None" obje

Re: About the implementation of del in Python 3

2017-07-07 Thread Steve D'Aprano
On Fri, 7 Jul 2017 06:05 pm, Gregory Ewing wrote: > Steve D'Aprano wrote: >> In practice, identity is hardly important in Python, except for a few limited >> cases, and the prohibition against using `is` when you mean `==`. > > On the contrary, it's a very important concept needed to make > sense

Re: About the implementation of del in Python 3

2017-07-07 Thread Steve D'Aprano
On Fri, 7 Jul 2017 05:45 pm, Chris Angelico wrote: > On Fri, Jul 7, 2017 at 4:43 PM, Steve D'Aprano > wrote: >> On Fri, 7 Jul 2017 01:41 am, Marko Rauhamaa wrote: >>> In Second-Order Logic, you can define identity directly: >>> >>> ∀x ∀y x = y ↔ ∀P (P(x) ↔ P(y)) >> >> Translating to English:

Re: About the implementation of del in Python 3

2017-07-07 Thread Steve D'Aprano
On Fri, 7 Jul 2017 05:29 pm, Dan Wissme wrote: > Strange behavior in Python 3.6.0 > >>> i = 3000 > >>> j = 3000 > >>> i is j > False > >>> n = 4000 ; m = 4000 ; n is m > True The Python interpreter is allowed to cache integers and reuse them. The interactive interpreter sometimes does so: if you

Re: About the implementation of del in Python 3

2017-07-07 Thread Gregory Ewing
Steve D'Aprano wrote: That implies that it is impossible to implement Scheme: - using a programming language where variables and objects may move during their lifetime; - or using a computing device without conventional memory, e.g. implementing Scheme using hydraulics, DNA computing, clockwork

Re: About the implementation of del in Python 3

2017-07-07 Thread Gregory Ewing
Marko Rauhamaa wrote: In Second-Order Logic, you can define identity directly: ∀x ∀y x = y ↔ ∀P (P(x) ↔ P(y)) That looks more like a definition of *equality* to me. In mathematics, everything is immutable, so there isn't really any distinction between equality and identity. -- Greg -- ht

Re: About the implementation of del in Python 3

2017-07-07 Thread Gregory Ewing
Steve D'Aprano wrote: In practice, identity is hardly important in Python, except for a few limited cases, and the prohibition against using `is` when you mean `==`. On the contrary, it's a very important concept needed to make sense of the way things behave when mutation is involved. Witness

Re: About the implementation of del in Python 3

2017-07-07 Thread Chris Angelico
On Fri, Jul 7, 2017 at 5:29 PM, Dan Wissme wrote: > Strange behavior in Python 3.6.0 i = 3000 j = 3000 i is j > False n = 4000 ; m = 4000 ; n is m > True Firstly, remember that immutables are allowed, but not required, to be shared. So this kind of "strange behaviour" is compl

Re: About the implementation of del in Python 3

2017-07-07 Thread Chris Angelico
On Fri, Jul 7, 2017 at 4:43 PM, Steve D'Aprano wrote: > On Fri, 7 Jul 2017 01:41 am, Marko Rauhamaa wrote: >> In Second-Order Logic, you can define identity directly: >> >> ∀x ∀y x = y ↔ ∀P (P(x) ↔ P(y)) > > Translating to English: > > For all x, for all y, x equals y if and only if for all P

Re: About the implementation of del in Python 3

2017-07-07 Thread Robin Becker
On 07/07/2017 07:42, Steve D'Aprano wrote: On Fri, 7 Jul 2017 03:05 am, Marko Rauhamaa wrote: ... [1] It may actually be instinctive -- there are studies that show that even young babies express surprise when they see something that violates the intuitive properties of identity. For e

Re: About the implementation of del in Python 3

2017-07-07 Thread Dan Wissme
Le 06/07/2017 à 20:56, Nathan Ernst a écrit : In Python, "==" is not a reference equality operator (and I hate Java for their misuse of the operator), so I absolutely disagree with using the Java description to describe Python's "==" operator, primarily because, well, it's wrong. Simple example:

Re: About the implementation of del in Python 3

2017-07-07 Thread Steve D'Aprano
On Fri, 7 Jul 2017 07:10 am, Marko Rauhamaa wrote: > I believe identity can be defined much better, in numerous isomorphic > ways in fact. > > For example, we could equate each object with a sequence number > (unrelated with its id()). You can define that the "None" object is in > fact the natura

Re: About the implementation of del in Python 3

2017-07-07 Thread Steve D'Aprano
On Fri, 7 Jul 2017 07:10 am, Marko Rauhamaa wrote: > Steve D'Aprano : > >> An address is a concrete location or place, in other words a physical >> position in some space, while identity is the abstract state or >> quality of being identical (sameness), in other words a state of >> being. > > Wh

Re: About the implementation of del in Python 3

2017-07-07 Thread Marko Rauhamaa
Steve D'Aprano : > On Fri, 7 Jul 2017 03:38 am, Marko Rauhamaa wrote: > >> Notice that Scheme refers directory to conventional RAM: >> >> Variables and objects such as pairs, vectors, and strings implicitly >> denote locations > > > That implies that it is impossible to implement Scheme: > > - us

Re: About the implementation of del in Python 3

2017-07-06 Thread Steve D'Aprano
On Fri, 7 Jul 2017 03:38 am, Marko Rauhamaa wrote: > Notice that Scheme refers directory to conventional RAM: > > Variables and objects such as pairs, vectors, and strings implicitly > denote locations That implies that it is impossible to implement Scheme: - using a programming language where

Re: About the implementation of del in Python 3

2017-07-06 Thread Steve D'Aprano
On Fri, 7 Jul 2017 03:05 am, Marko Rauhamaa wrote: > I believe the concept of an object is among the more difficult things > for novice programmers to get. True, but that has nothing to do with object identity. Inheritance, "is-a" versus "has-a" relationships, when to write len(x) versus x.len()

Re: About the implementation of del in Python 3

2017-07-06 Thread Steve D'Aprano
On Fri, 7 Jul 2017 01:41 am, Marko Rauhamaa wrote: > Here's how identity is dealt with in First-Order Logic: > >https://en.wikipedia.org/wiki/First-order_logic#Semantics> > > In other words, identity is mapped to the "sameness" in a domain of > discourse. Define "sameness". > In Second-

Re: About the implementation of del in Python 3

2017-07-06 Thread Marko Rauhamaa
Steve D'Aprano : > On Fri, 7 Jul 2017 08:56 am, Marko Rauhamaa wrote: > >> Google finds a Dutch master's thesis from 2009 that gives formal >> semantics to a subset of Python. I was interested in seeing how it >> treated identity. Lo and behold: >> >>The is operator determines whether its ope

Re: About the implementation of del in Python 3

2017-07-06 Thread Steve D'Aprano
On Fri, 7 Jul 2017 10:34 am, Gregory Ewing wrote: > Steve D'Aprano wrote: >> Address refers to a position in space. > > Not always. A PO Box number can remain the same when its owner's > location in space changes. But the PO box itself does not change. Pedantically, I guess it could: the post o

Re: About the implementation of del in Python 3

2017-07-06 Thread Steve D'Aprano
On Fri, 7 Jul 2017 08:56 am, Marko Rauhamaa wrote: > Google finds a Dutch master's thesis from 2009 that gives formal > semantics to a subset of Python. I was interested in seeing how it > treated identity. Lo and behold: > >The is operator determines whether its operands are the same object.

Re: About the implementation of del in Python 3

2017-07-06 Thread Steve D'Aprano
On Fri, 7 Jul 2017 07:46 am, Chris Angelico wrote: > A simple name lookup cannot, I believe, be messed with. Nor can a literal. In principle, you could replace builtins or globals with a custom namespace that performed some computation on name lookup. You might even be able to insert some additio

Re: About the implementation of del in Python 3

2017-07-06 Thread Chris Angelico
On Fri, Jul 7, 2017 at 10:34 AM, Gregory Ewing wrote: > Steve D'Aprano wrote: >> >> Address refers to a position in space. > > > Not always. A PO Box number can remain the same when its owner's > location in space changes. And IP addresses notoriously fail to > identify physical locations. A posi

Re: About the implementation of del in Python 3

2017-07-06 Thread Gregory Ewing
Steve D'Aprano wrote: Address refers to a position in space. Not always. A PO Box number can remain the same when its owner's location in space changes. And IP addresses notoriously fail to identify physical locations. -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: About the implementation of del in Python 3

2017-07-06 Thread Marko Rauhamaa
Chris Angelico : > On Fri, Jul 7, 2017 at 7:10 AM, Marko Rauhamaa wrote: >> Whether id() returns one such thing or not can't be discerned by a >> Python program. What's more, for any compliant implementation of id(), >> you can interpret the returned number as an address in some address >> space

Re: About the implementation of del in Python 3

2017-07-06 Thread Chris Angelico
On Fri, Jul 7, 2017 at 7:10 AM, Marko Rauhamaa wrote: > Steve D'Aprano : > >> An address is a concrete location or place, in other words a physical >> position in some space, while identity is the abstract state or >> quality of being identical (sameness), in other words a state of >> being. > > W

Re: About the implementation of del in Python 3

2017-07-06 Thread Marko Rauhamaa
Steve D'Aprano : > An address is a concrete location or place, in other words a physical > position in some space, while identity is the abstract state or > quality of being identical (sameness), in other words a state of > being. Whether id() returns one such thing or not can't be discerned by a

Re: About the implementation of del in Python 3

2017-07-06 Thread Nathan Ernst
In Python, "==" is not a reference equality operator (and I hate Java for their misuse of the operator), so I absolutely disagree with using the Java description to describe Python's "==" operator, primarily because, well, it's wrong. Simple example: With Python 3.5.2 (should hold for any version

Re: About the implementation of del in Python 3

2017-07-06 Thread Terry Reedy
Sorry, finger twitch. Wish there were a minute grace period to recall such mistakes. On 7/6/2017 2:16 PM, Terry Reedy wrote: -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list

Re: About the implementation of del in Python 3

2017-07-06 Thread Terry Reedy
On 7/6/2017 11:41 AM, Marko Rauhamaa wrote: Chris Angelico : The formal definition is that objects have identities, and that assignment (including function parameters and return values) gives you a reference to the same object. My example didn't contain a single assignment, but a variation of

Re: About the implementation of del in Python 3

2017-07-06 Thread Steve D'Aprano
On Fri, 7 Jul 2017 01:21 am, Marko Rauhamaa wrote: > Steve D'Aprano : > >> On Thu, 6 Jul 2017 07:24 pm, Marko Rauhamaa wrote: >> >>> While talking about addresses might or might not be constructive, let >>> me just point out that there is no outwardly visible distinction >>> between "address" or

Re: About the implementation of del in Python 3

2017-07-06 Thread Marko Rauhamaa
Marko Rauhamaa : > Notice that Scheme refers directory to conventional RAM: s/directory/directly/ -- https://mail.python.org/mailman/listinfo/python-list

Re: About the implementation of del in Python 3

2017-07-06 Thread Marko Rauhamaa
Ian Kelly : > On Thu, Jul 6, 2017 at 9:41 AM, Marko Rauhamaa wrote: >> As a good example of the style I'm looking for, take a look at: >> >>https://docs.oracle.com/javase/specs/jls/se7/html/jls-17.html> > > Java reference types have basically the same concept of identity as > Python objects,

Re: About the implementation of del in Python 3

2017-07-06 Thread Chris Angelico
On Fri, Jul 7, 2017 at 3:05 AM, Marko Rauhamaa wrote: > Chris Angelico : > >> On Fri, Jul 7, 2017 at 1:21 AM, Marko Rauhamaa wrote: >>> What I'm looking for is snippets of Python code that illustrate the >>> difference. >>> >>> That's how you can illustrate the difference between the "==" and "is

Re: About the implementation of del in Python 3

2017-07-06 Thread Marko Rauhamaa
Chris Angelico : > On Fri, Jul 7, 2017 at 1:21 AM, Marko Rauhamaa wrote: >> What I'm looking for is snippets of Python code that illustrate the >> difference. >> >> That's how you can illustrate the difference between the "==" and "is" >> operators: >> >> >>> ["a"] is ["a"] >> False >>

Re: About the implementation of del in Python 3

2017-07-06 Thread Ian Kelly
On Thu, Jul 6, 2017 at 9:41 AM, Marko Rauhamaa wrote: > As a good example of the style I'm looking for, take a look at: > >https://docs.oracle.com/javase/specs/jls/se7/html/jls-17.html> Java reference types have basically the same concept of identity as Python objects, so I dug around to find

Re: About the implementation of del in Python 3

2017-07-06 Thread Chris Angelico
On Fri, Jul 7, 2017 at 1:21 AM, Marko Rauhamaa wrote: > Steve D'Aprano : > >> On Thu, 6 Jul 2017 07:24 pm, Marko Rauhamaa wrote: >> >>> While talking about addresses might or might not be constructive, let >>> me just point out that there is no outwardly visible distinction >>> between "address" o

Re: About the implementation of del in Python 3

2017-07-06 Thread Chris Angelico
On Fri, Jul 7, 2017 at 12:59 AM, Marko Rauhamaa wrote: >> Or you are using "address" in some abstract sense so that the "address" >> does not change when the internal representation of the object is moved >> to another location. > > "Address" is just a word. In fact, I don't think there is any def

Re: About the implementation of del in Python 3

2017-07-06 Thread Jussi Piitulainen
Marko Rauhamaa writes: > Jussi Piitulainen: > >> For me it's enough to know that it's the object itself that is passed >> around as an argument, as a returned value, as a stored value, as a >> value of a variable. This is the basic fact that lets me understand >> the behaviour and performance of p

Re: About the implementation of del in Python 3

2017-07-06 Thread Chris Angelico
On Fri, Jul 7, 2017 at 12:56 AM, MRAB wrote: > Perhaps you should be thinking of it as passing around the end of a piece of > string, the other end being tied to the object itself. :-) You mean like Elbonian currency? http://dilbert.com/strip/2008-09-15 ChrisA -- https://mail.python.org/mailma

Re: About the implementation of del in Python 3

2017-07-06 Thread Marko Rauhamaa
Chris Angelico : > The formal definition is that objects have identities, and that > assignment (including function parameters and return values) gives you > a reference to the same object. My example didn't contain a single assignment, but a variation of your statement would make a good part in

Re: About the implementation of del in Python 3

2017-07-06 Thread Jussi Piitulainen
MRAB writes: > On 2017-07-06 15:29, Jussi Piitulainen wrote: >> Marko Rauhamaa writes: >> >>> While talking about addresses might or might not be constructive, >>> let me just point out that there is no outwardly visible distinction >>> between "address" or "identity". >> >> With a generational o

Re: About the implementation of del in Python 3

2017-07-06 Thread Marko Rauhamaa
Steve D'Aprano : > On Thu, 6 Jul 2017 07:24 pm, Marko Rauhamaa wrote: > >> While talking about addresses might or might not be constructive, let >> me just point out that there is no outwardly visible distinction >> between "address" or "identity". > > Er, yes there is. Address refers to a positio

Re: About the implementation of del in Python 3

2017-07-06 Thread Marko Rauhamaa
Jussi Piitulainen : > Marko Rauhamaa writes: > >> While talking about addresses might or might not be constructive, let >> me just point out that there is no outwardly visible distinction >> between "address" or "identity". > > With a generational or otherwise compacting garbage collector there >

Re: About the implementation of del in Python 3

2017-07-06 Thread MRAB
On 2017-07-06 15:29, Jussi Piitulainen wrote: Marko Rauhamaa writes: While talking about addresses might or might not be constructive, let me just point out that there is no outwardly visible distinction between "address" or "identity". With a generational or otherwise compacting garbage coll

Re: About the implementation of del in Python 3

2017-07-06 Thread Chris Angelico
On Thu, Jul 6, 2017 at 7:24 PM, Marko Rauhamaa wrote: > While talking about addresses might or might not be constructive, let me > just point out that there is no outwardly visible distinction between > "address" or "identity". > > Equally well, we could replace those words with: > >serial num

Re: About the implementation of del in Python 3

2017-07-06 Thread Jussi Piitulainen
Marko Rauhamaa writes: > While talking about addresses might or might not be constructive, let > me just point out that there is no outwardly visible distinction > between "address" or "identity". With a generational or otherwise compacting garbage collector there would be. I believe that to be a

Re: About the implementation of del in Python 3

2017-07-06 Thread Steve D'Aprano
On Thu, 6 Jul 2017 07:24 pm, Marko Rauhamaa wrote: > While talking about addresses might or might not be constructive, let me > just point out that there is no outwardly visible distinction between > "address" or "identity". Er, yes there is. Address refers to a position in space. Identity refer

Re: About the implementation of del in Python 3

2017-07-06 Thread Steve D'Aprano
On Thu, 6 Jul 2017 06:51 pm, Dan Wissme wrote: > So what 'del L[i]' do exactly in memory ? Same as L.pop(i) ? with > complexity O(n-i) ? It depends on what L is and what the value of i is. If L is a list, and i is the last index of the list, then deleting it is quick. If i is 0, then Python has t

Re: About the implementation of del in Python 3

2017-07-06 Thread Marko Rauhamaa
Chris Angelico : > On Thu, Jul 6, 2017 at 5:35 PM, Jussi Piitulainen > wrote: >> Incidentally, let no one point out that ids are not memory addresses. >> It says in the interactive help that they are (Python 3.4.0): >> [...] > > Sorry, not the case. > [...] > > id(...) > Return the identity o

Re: About the implementation of del in Python 3

2017-07-06 Thread Dan Wissme
Le 06/07/2017 à 09:29, Terry Reedy a écrit : On 7/6/2017 3:08 AM, Dan Wissme wrote: I thought that del L[i] would slide L[i+1:] one place to the left, filling the hole, but : >>> L [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100] >>> id(L) 4321967496 >>> id(L[5])# address of 50 ? 4297625504

Re: About the implementation of del in Python 3

2017-07-06 Thread Jussi Piitulainen
Chris Angelico writes: > On Thu, Jul 6, 2017 at 5:35 PM, Jussi Piitulainen > wrote: >> Incidentally, let no one point out that ids are not memory addresses. >> It says in the interactive help that they are (Python 3.4.0): >> >> Help on built-in function id in module builtins: >> >> id(...) >>

Re: About the implementation of del in Python 3

2017-07-06 Thread Dan Wissme
Le 06/07/2017 à 09:29, Terry Reedy a écrit : On 7/6/2017 3:08 AM, Dan Wissme wrote: I thought that del L[i] would slide L[i+1:] one place to the left, filling the hole, but : >>> L [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100] >>> id(L) 4321967496 >>> id(L[5])# address of 50 ? 4297625504

Re: About the implementation of del in Python 3

2017-07-06 Thread Chris Angelico
On Thu, Jul 6, 2017 at 5:35 PM, Jussi Piitulainen wrote: > Incidentally, let no one point out that ids are not memory addresses. > It says in the interactive help that they are (Python 3.4.0): > > Help on built-in function id in module builtins: > > id(...) > id(object) -> integer > > Retu

Re: About the implementation of del in Python 3

2017-07-06 Thread Jussi Piitulainen
Dan Wissme writes: > I thought that del L[i] would slide L[i+1:] one place to the left, > filling the hole, but : > L > [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100] id(L) > 4321967496 id(L[5])# address of 50 ? > 4297625504 del L[2] id(L[4]) # new address of 50 ? >

Re: About the implementation of del in Python 3

2017-07-06 Thread Terry Reedy
On 7/6/2017 3:08 AM, Dan Wissme wrote: I thought that del L[i] would slide L[i+1:] one place to the left, filling the hole, but : >>> L [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100] >>> id(L) 4321967496 >>> id(L[5])# address of 50 ? 4297625504 >>> del L[2] >>> id(L[4]) # new address

About the implementation of del in Python 3

2017-07-06 Thread Dan Wissme
I thought that del L[i] would slide L[i+1:] one place to the left, filling the hole, but : >>> L [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100] >>> id(L) 4321967496 >>> id(L[5])# address of 50 ? 4297625504 >>> del L[2] >>> id(L[4]) # new address of 50 ? 4297625504 >>> id(L) 4321967496 So