Comparing lists

2010-08-16 Thread Francesco Bochicchio
Hi all, anybody can point me to a description of how the default comparison of list objects (or other iterables) works? Apparently l1 l2 is equivalent to all ( x y for x,y in zip( l1, l2) ), has is shown in the following tests, but I can't find it described anywhere: [1,2,3] [1,3,2]

Re: Comparing lists

2010-08-16 Thread eliasf
On Mon, 16 Aug 2010 13:46:07 +0300, Francesco Bochicchio bieff...@gmail.com wrote: anybody can point me to a description of how the default comparison of list objects (or other iterables) works? Sequences of the same type are compared using lexicographical ordering:

Re: Comparing lists

2010-08-16 Thread Peter Otten
Francesco Bochicchio wrote: Hi all, anybody can point me to a description of how the default comparison of list objects (or other iterables) works? Apparently l1 l2 is equivalent to all ( x y for x,y in zip( l1, l2) ), has is shown in the following tests, but I can't find it

Comparing lists ...

2007-02-13 Thread Loic
I would like to know if it is possible, and how to do this with Python: I want to design a function to compare lists and return True only if both lists are equal considering memory location of the list. I suppose it would be the equivalent of comparing 2 pointers in c++ lets call this function

Re: Comparing lists ...

2007-02-13 Thread James Stroud
Loic wrote: I would like to know if it is possible, and how to do this with Python: I want to design a function to compare lists and return True only if both lists are equal considering memory location of the list. I suppose it would be the equivalent of comparing 2 pointers in c++ lets

Re: Comparing lists ...

2007-02-13 Thread Paul Rubin
Loic [EMAIL PROTECTED] writes: I want to design a function to compare lists and return True only if both lists are equal considering memory location of the list. I suppose it would be the equivalent of comparing 2 pointers in c++ Use the is keyword. print (l1 is l2) print (l0 is l2) --

Re: Comparing lists

2005-10-17 Thread Alex Martelli
Christian Stapfer [EMAIL PROTECTED] wrote: This is why we would like to have a way of (roughly) estimating the reasonableness of the outlines of a program's design in armchair fashion - i.e. without having to write any code and/or test harness. And we would also like to consume vast amounts

Re: Comparing lists

2005-10-17 Thread Christian Stapfer
Alex Martelli [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Christian Stapfer [EMAIL PROTECTED] wrote: This is why we would like to have a way of (roughly) estimating the reasonableness of the outlines of a program's design in armchair fashion - i.e. without having to write any

Re: Comparing lists

2005-10-17 Thread Alex Martelli
Christian Stapfer [EMAIL PROTECTED] wrote: Alex Martelli [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Christian Stapfer [EMAIL PROTECTED] wrote: This is why we would like to have a way of (roughly) estimating the reasonableness of the outlines of a program's design in

Re: Comparing lists

2005-10-17 Thread Paul Rubin
[EMAIL PROTECTED] (Alex Martelli) writes: implementation of the components one's considering! Rough ideas of *EXPECTED* run-times (big-Theta) for various subcomponents one is sketching are *MUCH* more interesting and important than asymptotic worst-case for amounts of input tending to

Re: Comparing lists

2005-10-17 Thread Christian Stapfer
Alex Martelli [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Christian Stapfer [EMAIL PROTECTED] wrote: Alex Martelli [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Christian Stapfer [EMAIL PROTECTED] wrote: This is why we would like to have a way of (roughly)

Re: Comparing lists

2005-10-16 Thread Ron Adam
Christian Stapfer wrote: This discussion begins to sound like the recurring arguments one hears between theoretical and experimental physicists. Experimentalists tend to overrate the importance of experimental data (setting up a useful experiment, how to interpret the experimental data one

Re: Comparing lists

2005-10-16 Thread Christian Stapfer
Ron Adam [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Christian Stapfer wrote: This discussion begins to sound like the recurring arguments one hears between theoretical and experimental physicists. Experimentalists tend to overrate the importance of experimental data (setting

Re: Comparing lists - somewhat OT, but still ...

2005-10-16 Thread Christian Stapfer
Ron Adam [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Christian Stapfer wrote: This discussion begins to sound like the recurring arguments one hears between theoretical and experimental physicists. Experimentalists tend to overrate the importance of experimental data (setting

Re: Comparing lists

2005-10-16 Thread Fredrik Lundh
Christian Stapfer wrote: As to the value of complexity theory for creativity in programming (even though you seem to believe that a theoretical bent of mind can only serve to stifle creativity), the story of the discovery of an efficient string searching algorithm by D.E.Knuth provides an

Re: Comparing lists - somewhat OT, but still ...

2005-10-16 Thread Steven D'Aprano
On Sun, 16 Oct 2005 15:16:39 +0200, Christian Stapfer wrote: Come to think of an experience that I shared with a student who was one of those highly creative experimentalists you seem to have in mind. He had just bought a new PC and wanted to check how fast its floating point unit was as

Re: Comparing lists

2005-10-16 Thread Ron Adam
Christian Stapfer wrote: Ron Adam [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Christian Stapfer wrote: This discussion begins to sound like the recurring arguments one hears between theoretical and experimental physicists. Experimentalists tend to overrate the importance of

Re: Comparing lists

2005-10-16 Thread Christian Stapfer
Fredrik Lundh [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Christian Stapfer wrote: As to the value of complexity theory for creativity in programming (even though you seem to believe that a theoretical bent of mind can only serve to stifle creativity), the story of the

Re: Comparing lists - somewhat OT, but still ...

2005-10-16 Thread Ron Adam
Christian Stapfer wrote: It turned out that the VAX compiler had been clever enough to hoist his simple-minded test code out of the driving loop. In fact, our VAX calculated the body of the loop only *once* and thus *immediately* announced that it had finished the whole test - the

Re: Comparing lists

2005-10-16 Thread Christian Stapfer
Ron Adam [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Christian Stapfer wrote: Ron Adam [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Christian Stapfer wrote: This discussion begins to sound like the recurring arguments one hears between theoretical and experimental

Re: Comparing lists

2005-10-16 Thread Steven D'Aprano
On Sun, 16 Oct 2005 19:42:11 +0200, Christian Stapfer wrote: Pauli's prediction of the existence of the neutrino is another. It took experimentalists a great deal of time and patience (about 20 years, I am told) until they could finally muster something amounting to experimental proof of

Re: Comparing lists - somewhat OT, but still ...

2005-10-16 Thread Christian Stapfer
Steven D'Aprano [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On Sun, 16 Oct 2005 15:16:39 +0200, Christian Stapfer wrote: Come to think of an experience that I shared with a student who was one of those highly creative experimentalists you seem to have in mind. He had just

Re: Comparing lists

2005-10-16 Thread Christian Stapfer
Steven D'Aprano [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On Sun, 16 Oct 2005 19:42:11 +0200, Christian Stapfer wrote: Pauli's prediction of the existence of the neutrino is another. It took experimentalists a great deal of time and patience (about 20 years, I am told) until

Re: Comparing lists

2005-10-16 Thread Ron Adam
Christian Stapfer wrote: Ron Adam [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Christian Stapfer wrote: Ron Adam [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Christian Stapfer wrote: This discussion begins to sound like the recurring arguments one hears between

Re: Comparing lists - somewhat OT, but still ...

2005-10-16 Thread Ognen Duzlevski
Steven D'Aprano [EMAIL PROTECTED] wrote: On Sun, 16 Oct 2005 15:16:39 +0200, Christian Stapfer wrote: It turned out that the VAX compiler had been clever enough to hoist his simple-minded test code out of the driving loop. Optimizations have a tendency to make a complete mess of Big

Re: Comparing lists - somewhat OT, but still ...

2005-10-16 Thread Paul Rubin
Ognen Duzlevski [EMAIL PROTECTED] writes: Optimizations have a tendency to make a complete mess of Big O calculations, usually for the better. How does this support your theory that Big O is a reliable predictor of program speed? There are many things that you cannot predict, however if

Re: Comparing lists - somewhat OT, but still ...

2005-10-16 Thread Steven D'Aprano
On Sun, 16 Oct 2005 20:28:55 +0200, Christian Stapfer wrote: Experiments (not just in computer science) are quite frequently botched. How do you discover botched experiments? Normally by comparing them to the results of other experiments, and being unable to reconcile the results. You may

Re: Comparing lists - somewhat OT, but still ...

2005-10-16 Thread Steven D'Aprano
On Sun, 16 Oct 2005 14:07:37 -0700, Paul Rubin wrote: The complexity of hashing depends intricately on the the data and if the data is carefully constructed by someone with detailed knowledge of the hash implementation, it may be as bad as O(n) rather than O(1) or O(sqrt(n)) or anything like

Re: Comparing lists

2005-10-16 Thread James Dennett
Steven D'Aprano wrote: On Sat, 15 Oct 2005 18:17:36 +0200, Christian Stapfer wrote: I'd prefer a (however) rough characterization of computational complexity in terms of Big-Oh (or Big-whatever) *anytime* to marketing-type characterizations like this one... Oh how naive. Why is it that even

Re: Comparing lists - somewhat OT, but still ...

2005-10-16 Thread Paul Rubin
Steven D'Aprano [EMAIL PROTECTED] writes: But if you are unlikely to discover this worst case behaviour by experimentation, you are equally unlikely to discover it in day to day usage. Yes, that's the whole point. Since you won't discover it by experimentation and you won't discover it by day

Re: Comparing lists

2005-10-15 Thread Steven D'Aprano
On Sat, 15 Oct 2005 06:31:53 +0200, Christian Stapfer wrote: jon [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] To take the heat out of the discussion: sets are blazingly fast. I'd prefer a (however) rough characterization of computational complexity in terms of Big-Oh (or

Re: Comparing lists

2005-10-15 Thread Christian Stapfer
Steven D'Aprano [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On Sat, 15 Oct 2005 06:31:53 +0200, Christian Stapfer wrote: jon [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] To take the heat out of the discussion: sets are blazingly fast. I'd prefer a (however)

Re: Comparing lists

2005-10-15 Thread Steven D'Aprano
On Sat, 15 Oct 2005 18:17:36 +0200, Christian Stapfer wrote: I'd prefer a (however) rough characterization of computational complexity in terms of Big-Oh (or Big-whatever) *anytime* to marketing-type characterizations like this one... Oh how naive. Why is it that even computer science

Re: Comparing lists

2005-10-15 Thread Christian Stapfer
Steven D'Aprano [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On Sat, 15 Oct 2005 18:17:36 +0200, Christian Stapfer wrote: I'd prefer a (however) rough characterization of computational complexity in terms of Big-Oh (or Big-whatever) *anytime* to marketing-type characterizations

Re: Comparing lists

2005-10-14 Thread Scott David Daniels
Let me begin by apologizing to Christian as I was too snippy in my reply, and sounded even snippier than I meant to. Christian Stapfer wrote: Scott David Daniels [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] a better set implementation will win if it can show better performance

Re: Comparing lists

2005-10-14 Thread Christian Stapfer
jon [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] To take the heat out of the discussion: sets are blazingly fast. I'd prefer a (however) rough characterization of computational complexity in terms of Big-Oh (or Big-whatever) *anytime* to marketing-type characterizations like

Re: Comparing lists

2005-10-13 Thread jon
To take the heat out of the discussion: sets are blazingly fast. -- http://mail.python.org/mailman/listinfo/python-list

Re: Comparing lists

2005-10-11 Thread Scott David Daniels
Christian Stapfer wrote: Steve Holden [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Christian Stapfer wrote: George Sakkis [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Christian Stapfer [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: try to use set. A

Re: Comparing lists

2005-10-11 Thread Christian Stapfer
Scott David Daniels [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Christian Stapfer wrote: Steve Holden [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Christian Stapfer wrote: George Sakkis [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Christian Stapfer

Comparing lists

2005-10-10 Thread Odd-R.
I have to lists, A and B, that may, or may not be equal. If they are not identical, I want the output to be three new lists, X,Y and Z where X has all the elements that are in A, but not in B, and Y contains all the elements that are B but not in A. Z will then have the elements that are in

Re: Comparing lists

2005-10-10 Thread Laszlo Zsolt Nagy
Odd-R. wrote: I have to lists, A and B, that may, or may not be equal. If they are not identical, I want the output to be three new lists, X,Y and Z where X has all the elements that are in A, but not in B, and Y contains all the elements that are B but not in A. Z will then have the elements

Re: Comparing lists

2005-10-10 Thread [EMAIL PROTECTED]
try to use set. L1 = [1,1,2,3,4] L2 = [1,3, 99] A = set(L1) B = set(L2) X = A-B print X Y = B-A print Y Z = A | B print Z Cheers, pujo -- http://mail.python.org/mailman/listinfo/python-list

Re: Comparing lists

2005-10-10 Thread Christian Stapfer
[EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] try to use set. L1 = [1,1,2,3,4] L2 = [1,3, 99] A = set(L1) B = set(L2) X = A-B print X Y = B-A print Y Z = A | B print Z But how efficient is this? Could you be a bit more explicit on that

Re: Comparing lists

2005-10-10 Thread George Sakkis
Christian Stapfer [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: try to use set. Sorting the two lists and then extracting A-B, B-A, A|B, A B and A ^ B in one single pass seems to me very likely to be much faster for large lists. Why don't you implement it, test it and time it to

Re: Comparing lists

2005-10-10 Thread Steven D'Aprano
On Mon, 10 Oct 2005 14:34:35 +0200, Christian Stapfer wrote: Sorting the two lists and then extracting A-B, B-A, A|B, A B and A ^ B in one single pass seems to me very likely to be much faster for large lists. Unless you are running a Python compiler in your head, chances are your intuition

Re: Comparing lists

2005-10-10 Thread Christian Stapfer
George Sakkis [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Christian Stapfer [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: try to use set. Sorting the two lists and then extracting A-B, B-A, A|B, A B and A ^ B in one single pass seems to me very likely to be much

Re: Comparing lists

2005-10-10 Thread Steve Holden
Christian Stapfer wrote: George Sakkis [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Christian Stapfer [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: try to use set. Sorting the two lists and then extracting A-B, B-A, A|B, A B and A ^ B in one single pass seems to me

Re: Comparing lists

2005-10-10 Thread Christian Stapfer
Steve Holden [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Christian Stapfer wrote: George Sakkis [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Christian Stapfer [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: try to use set. Sorting the two lists and then