RE: To clarify how Python handles two equal objects

2023-01-13 Thread Jen Kris via Python-list
Avi, Thanks for your comments.  You make a good point.  Going back to my original question, and using your slice() example:  middle_by_two = slice(5, 10, 2) nums = [n for n in range(12)] q = nums[middle_by_two] x = id(q) b = q y = id(b) If I assign "b" to "q", then x and y match – they point t

Re: To clarify how Python handles two equal objects

2023-01-13 Thread Bob van der Poel
It seems to me that the the entire concept of relying on python's idea of where an object is stored is just plain dangerous. A most simple example might be: >>> a=1 >>> b=1 >>> a is b True >>> a=1234 >>> b=1234 >>> a is b False Not sure what happens if you manipulate the data re

Re: To clarify how Python handles two equal objects

2023-01-13 Thread Axel Reichert
writes: > As an example, you can create a named slice such as: > > middle_by_two = slice(5, 10, 2) > > The above is not in any sense pointing at anything yet. >From a functional programming point of view this just looks like a partially applied function, and with this in mind the behaviour to

Re: The Zen of D.E.K.

2023-01-13 Thread Ethan Furman
On 1/13/23 09:06, Stefan Ram wrote: >"Beautiful is better than ugly." - The Zen of Python > >This says nothing. You have to sacrifice something that >really has /value/! > >"[A]esthetics are more important than efficiency." - Donald E. Knuth [okay, falling for the troll bait] Th

Re: To clarify how Python handles two equal objects

2023-01-13 Thread Jen Kris via Python-list
Bob, Your examples show a and b separately defined.  My example is where the definition is a=1; b = a.  But I'm only interested in arrays.  I would not rely on this for integers, and there's not likely to be any real cost savings there.   Jan 13, 2023, 08:45 by b...@mellowood.ca: > It seem

Re: To clarify how Python handles two equal objects

2023-01-13 Thread Peter J. Holzer
On 2023-01-13 16:57:45 +0100, Jen Kris via Python-list wrote: > Thanks for your comments.  You make a good point.  > > Going back to my original question, and using your slice() example:  > > middle_by_two = slice(5, 10, 2) > nums = [n for n in range(12)] > q = nums[middle_by_two] > x = id(q) > b

Re: The Zen of D.E.K.

2023-01-13 Thread Peter J. Holzer
On 2023-01-13 10:00:01 -0800, Ethan Furman wrote: > On 1/13/23 09:06, Stefan Ram wrote: > >"Beautiful is better than ugly." - The Zen of Python > > > >This says nothing. You have to sacrifice something that > >really has /value/! Time? Making something beautiful takes time. > >"

RE: To clarify how Python handles two equal objects

2023-01-13 Thread avi.e.gross
Jen, This may not be on target but I was wondering about your needs in this category. Are all your data in a form where all in a cluster are the same object type, such as floating point? Python has features designed to allow you to get multiple views on such objects such as memoryview that can

RE: To clarify how Python handles two equal objects

2023-01-13 Thread avi.e.gross
Jen, Can a compiler, or spot compiler, always know if something that was a reference is changed? Obvious examples may be if a change happens in non-deterministic ways such as in a fork chosen at random or from user input but also sometimes levels of indirection such as deleting an object

RE: To clarify how Python handles two equal objects

2023-01-13 Thread avi.e.gross
Axel and others, I can appreciate the comparison to a partially applied function but not in this case. Not that it matters, but this example is more like creating an object in something like machine learning and initializing parameters without adding data. Only when you ad data and call upon some