Re: Binary Sort on Python List __xor__

2020-06-01 Thread Rhodri James
On 31/05/2020 18:01, Evan Schalton wrote: I think you're arguing both sides of the argument -- numpy arrays do have a lot of similar, related operations (because numpy uses them internally -- since they're more efficient) which means they're not fringe. I'm advocating that the built-in list clas

Re: Binary Sort on Python List __xor__

2020-05-31 Thread Terry Reedy
On 5/31/2020 12:24 PM, Evan Schalton wrote: I'm less strictly interested in the & operator explicitly working with a bit int, but think it'd be great if the was a built-in filter something like: [1,2,3,4] & [0,0,1,1] => [3,4] OR [1,2,3,4] & [False, False, True, True] = [3,4] Leaving numpy

Re: Binary Sort on Python List __xor__

2020-05-31 Thread Evan Schalton
I think you're arguing both sides of the argument -- numpy arrays do have a lot of similar, related operations (because numpy uses them internally -- since they're more efficient) which means they're not fringe. I'm advocating that the built-in list class add the efficient, convenience methods

Re: Binary Sort on Python List __xor__

2020-05-31 Thread Peter Otten
Evan Schalton wrote: > Peter, > > This isn't a ram consideration as much it's a logical consideration. There > are a lot of ways to handle this, I REALLY don't want to use a package > here. Bit masking is incredibly useful for permutations/combinatoric > algorithms. I can create my own class wrap

Re: Binary Sort on Python List __xor__

2020-05-31 Thread Evan Schalton
Peter, This isn't a ram consideration as much it's a logical consideration. There are a lot of ways to handle this, I REALLY don't want to use a package here. Bit masking is incredibly useful for permutations/combinatoric algorithms. I can create my own class wrapper or functions, and optimize,

Re: Binary Sort on Python List __xor__

2020-05-31 Thread Peter Otten
evan.schal...@gmail.com wrote: > I frequently use binary as bool placeholders and find myself filtering > lists based on those bools, this seems to have a similar semantic meaning > as the bit wise ^ or __xor__ operator and could add syntactic sugar to the > base list class. > > Use Case: > > Co

Re: Binary Sort on Python List __xor__

2020-05-30 Thread Evan Schalton
@MRAB, Yes -- good point, it should be the __and__ operator. do I need a new class? No, but based on this use case and other formatting techniques adding a filter method to the list class that takes in either bit mask or bool list would streamline a lot of code and not change any existing func

Re: Binary Sort on Python List __xor__

2020-05-30 Thread MRAB
On 2020-05-30 23:52, evan.schal...@gmail.com wrote: I frequently use binary as bool placeholders and find myself filtering lists based on those bools, this seems to have a similar semantic meaning as the bit wise ^ or __xor__ operator and could add syntactic sugar to the base list class. Use C

Re: binary decision diagrams

2017-12-20 Thread Devin Jeanpierre
On Mon, Dec 18, 2017 at 5:00 AM, Wild, Marcel, Dr wrote: > Hello everybody: > I really don't know anything about Python (I'm using Mathematica) but with > the help of others learned that > > g=expr2bdd(f) > > makes the BDD (=binary decision diagram) g of a Boolean function f. But > what is th

Re: Binary data exchange

2014-05-29 Thread Mark Lawrence
On 30/05/2014 00:25, rasikasriniva...@gmail.com wrote: Of course Cut and paste issue. Anyhow, i will look at the struct module. cheers, srini Please let us know how you get on, please don't top post, and please either use the mailing list https://mail.python.org/mailman/listinfo/python-

Re: Binary data exchange

2014-05-29 Thread rasikasriniva...@gmail.com
Of course Cut and paste issue. Anyhow, i will look at the struct module. cheers, srini On Thursday, May 29, 2014 7:09:21 PM UTC-4, MRAB wrote: > On 2014-05-29 23:08, rasikasriniva...@gmail.com wrote: > > > friends > > > > > > I have a pair of simple python programs as follows: > > > > >

Re: Binary data exchange

2014-05-29 Thread Ian Kelly
On Thu, May 29, 2014 at 5:09 PM, MRAB wrote: > On 2014-05-29 23:08, rasikasriniva...@gmail.com wrote: >> the received data for the messages 9 thru 13 are not as expected. >> >> I wonder if anyone can see what I am doing wrong? >> >> Appreciate any hints. thanks, srini >> > I don't understand why y

Re: Binary data exchange

2014-05-29 Thread MRAB
On 2014-05-29 23:08, rasikasriniva...@gmail.com wrote: friends I have a pair of simple python programs as follows: #!/usr/bin/python # broadcast.py import socket from ctypes import * import random class PurgeData(Structure): _fields_ = [("press",c_int), ("ticks",c_int), ("volume",c_float)

Re: Binary data exchange

2014-05-29 Thread rasikasriniva...@gmail.com
BTW - My environment is: H:\>python Enthought Canopy Python 2.7.6 | 64-bit | (default, Apr 11 2014, 20:31:44) [MSC v .1500 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> -- https://mail.python.org/mailman/listinfo/python-list

Re: binary key in dictionary

2013-07-31 Thread John Gordon
In <9004a556-958f-4d1d-81a7-4d1b73134...@googlegroups.com> cerr writes: > Traceback (most recent call last): > File "gateway.py", line 2485, in > main() > File "gateway.py", line 2459, in main > cloud_check() > File "gateway.py", line 770, in cloud_check > gnstr_dict[src] = gn

Re: binary key in dictionary

2013-07-30 Thread Gary Herron
On 07/30/2013 01:29 PM, cerr wrote: Hi, In my application I have followingf lines: print curr_mac print hexlify(buf) binmac = unhexlify(curr_mac) tmpgndict[binmac] += buf curr_mac being a 3Byte MAVC address in ASCII and I want t

Re: Binary for numpy 1.7.0 with Python 2.7.3

2013-03-21 Thread Miki Tebeka
> I'm trying to update to both 2.7.3 and Numpy 1.7.0. Updating Python is from python.org If you're on 64bit windows, see http://www.lfd.uci.edu/~gohlke/pythonlibs/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Binary for numpy 1.7.0 with Python 2.7.3

2013-03-21 Thread Colin J. Williams
On 21/03/2013 4:00 PM, Dave Angel wrote: On 03/21/2013 03:40 PM, Colin J. Williams wrote: How do I find the binaries on Source Forge? I'm trying to update to both 2.7.3 and Numpy 1.7.0. Colin W Best answer might depend on what OS you're running, and what implementation of Python you're after

Re: Binary for numpy 1.7.0 with Python 2.7.3

2013-03-21 Thread Kwpolska
On Thu, Mar 21, 2013 at 8:40 PM, Colin J. Williams wrote: > How do I find the binaries on Source Forge? > > I'm trying to update to both 2.7.3 and Numpy 1.7.0. > > Colin W > -- > http://mail.python.org/mailman/listinfo/python-list You don’t. First off, nobody really likes nor uses SourceForge to

Re: Binary for numpy 1.7.0 with Python 2.7.3

2013-03-21 Thread Dave Angel
On 03/21/2013 03:40 PM, Colin J. Williams wrote: How do I find the binaries on Source Forge? I'm trying to update to both 2.7.3 and Numpy 1.7.0. Colin W Best answer might depend on what OS you're running, and what implementation of Python you're after. Why would you look on SourceForge for

Re: Binary tree implementation

2013-02-14 Thread Gary Herron
On 02/14/2013 11:18 AM, Megha Agrawal wrote: Hello All, I am a newbie to python language. I need your help in implementation of Binary tree in python. I have a count of nodes and I need to draw a binary tree. Suppose if count is 5 then tree will look like 1

Re: binary vtk file

2010-10-11 Thread Robert Kern
On 10/11/10 5:16 AM, Paul Biegel wrote: Hi, I have a question related to read a binary vtk file. This file has been created using Matlab by the command "fread". However, this file must be processed further within Python. It is not known to me which codec is used to encode this file. It starts wit

Re: Binary compatibility across Python versions?

2010-07-27 Thread Ned Deily
In article <0a4c9b21-6eff-461a-b15c-415d1408d...@semanchuk.com>, Philip Semanchuk wrote: [...] > Thanks to all who replied on this topic. A little more background -- > these binaries are just a convenience for our users and we don't have > to cover every possible permutation of Python, only t

Re: Binary compatibility across Python versions?

2010-07-27 Thread Philip Semanchuk
On Jul 26, 2010, at 5:19 PM, Ned Deily wrote: In article , Christian Heimes wrote: [Philip Semanchuk wrote:] Specifically, I'm concerned with binaries created by SWIG for a C++ library that our project uses. We'd like to ship precompiled binaries for Linux, OS X and Windows for Python 2.5

Re: Binary compatibility across Python versions?

2010-07-26 Thread Ned Deily
In article , Christian Heimes wrote: > [Philip Semanchuk wrote:] > > Specifically, I'm concerned with binaries created by SWIG for a C++ > > library that our project uses. We'd like to ship precompiled binaries > > for Linux, OS X and Windows for Python 2.5 and 2.6. I'm hoping that it > > i

Re: Binary compatibility across Python versions?

2010-07-26 Thread Robert Kern
On 7/26/10 2:40 PM, MRAB wrote: Philip Semanchuk wrote: Hi all, Does Python guarantee binary compatibility across major, minor and/or micro versions? I looked through the docs and even with Google's help I wasn't able to find any official statements on this subject. Specifically, I'm concerned

Re: Binary compatibility across Python versions?

2010-07-26 Thread Christian Heimes
> Specifically, I'm concerned with binaries created by SWIG for a C++ > library that our project uses. We'd like to ship precompiled binaries > for Linux, OS X and Windows for Python 2.5 and 2.6. I'm hoping that it > is sufficient to create binaries for each Python for each platform (3 > *

Re: Binary compatibility across Python versions?

2010-07-26 Thread MRAB
Philip Semanchuk wrote: Hi all, Does Python guarantee binary compatibility across major, minor and/or micro versions? I looked through the docs and even with Google's help I wasn't able to find any official statements on this subject. Specifically, I'm concerned with binaries created by SWIG

Re: Binary Decimals in Python

2010-03-30 Thread Mensanator
On Mar 30, 1:52 pm, MRAB wrote: > John Nagle wrote: > > aditya wrote: > >> On Mar 30, 10:49 am, Raymond Hettinger wrote: > >>> On Mar 30, 8:13 am, aditya wrote: > > To get the decimal representation of a binary number, I can just do > this: > int('11',2) # returns 3 > But dec

Re: Binary Decimals in Python

2010-03-30 Thread Chris Kaynor
Chris On Tue, Mar 30, 2010 at 11:14 AM, John Nagle wrote: > aditya wrote: > >> On Mar 30, 10:49 am, Raymond Hettinger wrote: >> >>> On Mar 30, 8:13 am, aditya wrote: >>> >>> To get the decimal representation of a binary number, I can just do this: int('11',2) # returns 3 But d

Re: Binary Decimals in Python

2010-03-30 Thread MRAB
John Nagle wrote: aditya wrote: On Mar 30, 10:49 am, Raymond Hettinger wrote: On Mar 30, 8:13 am, aditya wrote: To get the decimal representation of a binary number, I can just do this: int('11',2) # returns 3 But decimal binary numbers throw a ValueError: int('1.1',2) # should return 1.5,

Re: Binary Decimals in Python

2010-03-30 Thread Grant Edwards
On 2010-03-30, John Nagle wrote: > Hex floats are useful because you can get a string representation of > the exact value of a binary floating point number. It should always > be the case that > >float.fromhex(float.hex(x)) == x Until you try running your program on a machine that repre

Re: Binary Decimals in Python

2010-03-30 Thread Mensanator
On Mar 30, 10:49 am, Raymond Hettinger wrote: > On Mar 30, 8:13 am, aditya wrote: > > > To get the decimal representation of a binary number, I can just do > > this: > > > int('11',2) # returns 3 > > > But decimal binary numbers throw a ValueError: > > > int('1.1',2) # should return 1.5, throws e

Re: Binary Decimals in Python

2010-03-30 Thread John Nagle
aditya wrote: On Mar 30, 10:49 am, Raymond Hettinger wrote: On Mar 30, 8:13 am, aditya wrote: To get the decimal representation of a binary number, I can just do this: int('11',2) # returns 3 But decimal binary numbers throw a ValueError: int('1.1',2) # should return 1.5, throws error instea

Re: Binary Decimals in Python

2010-03-30 Thread Steven D'Aprano
On Tue, 30 Mar 2010 08:28:50 -0700, Patrick Maupin wrote: > On Mar 30, 10:13 am, aditya wrote: >> To get the decimal representation of a binary number, I can just do >> this: >> >> int('11',2) # returns 3 >> >> But decimal binary numbers throw a ValueError: >> >> int('1.1',2) # should return 1.5,

Re: Binary Decimals in Python

2010-03-30 Thread aditya
On Mar 30, 10:49 am, Raymond Hettinger wrote: > On Mar 30, 8:13 am, aditya wrote: > > > To get the decimal representation of a binary number, I can just do > > this: > > > int('11',2) # returns 3 > > > But decimal binary numbers throw a ValueError: > > > int('1.1',2) # should return 1.5, throws e

Re: Binary Decimals in Python

2010-03-30 Thread aditya
On Mar 30, 10:37 am, Benjamin Kaplan wrote: > On Tue, Mar 30, 2010 at 11:13 AM, aditya wrote: > > To get the decimal representation of a binary number, I can just do > > this: > > > int('11',2) # returns 3 > > > But decimal binary numbers throw a ValueError: > > > int('1.1',2) # should return 1.5

Re: Binary Decimals in Python

2010-03-30 Thread MRAB
aditya wrote: To get the decimal representation of a binary number, I can just do this: int('11',2) # returns 3 But decimal binary numbers throw a ValueError: int('1.1',2) # should return 1.5, throws error instead. Is this by design? It seems to me that this is not the correct behavior. int

Re: Binary Decimals in Python

2010-03-30 Thread Grant Olson
Doh! Well the problem is that int's are integers. So yeah, you can't even do that with normal value "int ('2.1')" will also throw an error. And floats don't support radix conversion, because no-one really writes numbers that way. (At least computer programmers...) On 3/30/2010 11:43 AM, Shash

Re: Binary Decimals in Python

2010-03-30 Thread Raymond Hettinger
On Mar 30, 8:13 am, aditya wrote: > To get the decimal representation of a binary number, I can just do > this: > > int('11',2) # returns 3 > > But decimal binary numbers throw a ValueError: > > int('1.1',2) # should return 1.5, throws error instead. > > Is this by design? It seems to me that this

Re: Binary Decimals in Python

2010-03-30 Thread Shashwat Anand
The conversion is not supported for decimal integers AFAIK, however '0b123.456' is always valid. I guess you can always get a decimal number convertor onto Python-recipes On Tue, Mar 30, 2010 at 9:05 PM, Grant Olson wrote: > On 3/30/2010 11:13 AM, aditya wrote: > > To get the decimal represent

Re: Binary Decimals in Python

2010-03-30 Thread Benjamin Kaplan
On Tue, Mar 30, 2010 at 11:13 AM, aditya wrote: > To get the decimal representation of a binary number, I can just do > this: > > int('11',2) # returns 3 > > But decimal binary numbers throw a ValueError: > > int('1.1',2) # should return 1.5, throws error instead. > > Is this by design? It seems t

Re: Binary Decimals in Python

2010-03-30 Thread Grant Olson
On 3/30/2010 11:13 AM, aditya wrote: > To get the decimal representation of a binary number, I can just do > this: > > int('11',2) # returns 3 > > But decimal binary numbers throw a ValueError: > > int('1.1',2) # should return 1.5, throws error instead. > > Is this by design? It seems to me tha

Re: Binary Decimals in Python

2010-03-30 Thread Patrick Maupin
On Mar 30, 10:13 am, aditya wrote: > To get the decimal representation of a binary number, I can just do > this: > > int('11',2) # returns 3 > > But decimal binary numbers throw a ValueError: > > int('1.1',2) # should return 1.5, throws error instead. > > Is this by design? It seems to me that thi

Re: Binary Decimals in Python

2010-03-30 Thread Shashwat Anand
decimal binary number is not included AFAIK On Tue, Mar 30, 2010 at 8:43 PM, aditya wrote: > To get the decimal representation of a binary number, I can just do > this: > > int('11',2) # returns 3 > > But decimal binary numbers throw a ValueError: > > int('1.1',2) # should return 1.5, throws err

Re: Binary data transfer issue

2010-03-15 Thread MRAB
Jordan Apgar wrote: Hi all, I'm trying to transfer a binary file over xmlrpclib. My test file is a .jpeg file. I can transfer all the data over but when I go to open the .jpeg I get "Error interpreting JPEG image file (Invalid JPEG file structure: SOS before SOF)" here's the code: =

Re: binary literal

2009-07-23 Thread superpollo
Hendrik van Rooyen wrote: On Wednesday 22 July 2009 12:03:44 superpollo wrote: can i do something like the above, but using a *binary* number? (e.g. 00101101 instead of 45) ? 00101101 is not hex 45. hex 45 is 01000101 whoopsie daisie! chr(int('01000101',2)) 'E' much obliged. by

Re: binary literal

2009-07-23 Thread Hendrik van Rooyen
On Wednesday 22 July 2009 12:03:44 superpollo wrote: > can i do something like the above, but using a *binary* number? (e.g. > 00101101 instead of 45) ? 00101101 is not hex 45. hex 45 is 01000101 >>> chr(int('01000101',2)) 'E' >>> - Hendrik -- http://mail.python.org/mailman/listinfo/python-

Re: binary literal

2009-07-22 Thread Terry Reedy
superpollo wrote: hello clp. i can insert a hex value for a character literal in a string: >>> stuff = "\x45" >>> print stuff E >>> can i do something like the above, but using a *binary* number? (e.g. 00101101 instead of 45) ? Language Ref 2.4. Literals -- http://mail.python.org/mailma

Re: binary literal

2009-07-22 Thread Dave Angel
superpollo wrote: hello clp. i can insert a hex value for a character literal in a string: >>> stuff = "\x45" >>> print stuff E >>> can i do something like the above, but using a *binary* number? (e.g. 00101101 instead of 45) ? bye There's no way to get a binary value directly into a lit

Re: binary literal

2009-07-22 Thread Ulrich Eckhardt
superpollo wrote: > i can insert a hex value for a character literal in a string: > > >>> stuff = "\x45" > >>> print stuff > E > >>> > > can i do something like the above, but using a *binary* number? (e.g. > 00101101 instead of 45) ? There are binary number literals since 2.6 and there is th

Re: binary literal

2009-07-22 Thread Pablo Martí Gamboa
2009/7/22 superpollo > hello clp. > > i can insert a hex value for a character literal in a string: > > >>> stuff = "\x45" > >>> print stuff > E > >>> > > can i do something like the above, but using a *binary* number? (e.g. > 00101101 instead of 45) ? (Python 3) >>> bin(45) '0b101101' >>> in

Re: Binary IP address representation

2009-04-22 Thread Philipp Hagemeister
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 Hi Dave, I've solved this now using ipaddr. ipaddr will be in the stdlib as soon as its developers realize there are actually not one, but two proposals to fix the remaining issues waiting for their input. Anyway, since ipaddr:r68, you can do the f

Re: binary file compare...

2009-04-18 Thread Piet van Oostrum
> Adam Olsen (AO) wrote: >AO> The Wayback Machine has 150 billion pages, so 2**37. Google's index >AO> is a bit larger at over a trillion pages, so 2**40. A little closer >AO> than I'd like, but that's still 56294995000 to 1 odds of having >AO> *any* collisions between *any* of the file

Re: binary file compare...

2009-04-17 Thread Steven D'Aprano
On Fri, 17 Apr 2009 11:19:31 -0700, Adam Olsen wrote: > Actually, *cryptographic* hashes handle that just fine. Even for files > with just a 1 bit change the output is totally different. This is known > as the Avalanche Effect. Otherwise they'd be vulnerable to attacks. > > Which isn't to say

Re: binary file compare...

2009-04-17 Thread Lawrence D'Oliveiro
In message , Nigel Rantor wrote: > Adam Olsen wrote: > >> The chance of *accidentally* producing a collision, although >> technically possible, is so extraordinarily rare that it's completely >> overshadowed by the risk of a hardware or software failure producing >> an incorrect result. > > Not

Re: binary file compare...

2009-04-17 Thread Adam Olsen
On Apr 17, 9:59 am, SpreadTooThin wrote: > You know this is just insane.  I'd be satisfied with a CRC16 or > something in the situation i'm in. > I have two large files, one local and one remote.  Transferring every > byte across the internet to be sure that the two files are identical > is just n

Re: binary file compare...

2009-04-17 Thread Adam Olsen
On Apr 17, 9:59 am, norseman wrote: > The more complicated the math the harder it is to keep a higher form of > math from checking (or improperly displacing) a lower one.  Which, of > course, breaks the rules.  Commonly called improper thinking. A number > of math teasers make use of that. Of cou

Re: binary file compare...

2009-04-17 Thread Adam Olsen
On Apr 17, 5:30 am, Tim Wintle wrote: > On Thu, 2009-04-16 at 21:44 -0700, Adam Olsen wrote: > > The Wayback Machine has 150 billion pages, so 2**37.  Google's index > > is a bit larger at over a trillion pages, so 2**40.  A little closer > > than I'd like, but that's still 56294995000 to 1 od

Re: binary file compare...

2009-04-17 Thread SpreadTooThin
On Apr 17, 4:54 am, Nigel Rantor wrote: > Adam Olsen wrote: > > On Apr 16, 11:15 am, SpreadTooThin wrote: > >> And yes he is right CRCs hashing all have a probability of saying that > >> the files are identical when in fact they are not. > > > Here's the bottom line.  It is either: > > > A) Sever

Re: binary file compare...

2009-04-17 Thread norseman
Adam Olsen wrote: On Apr 16, 11:15 am, SpreadTooThin wrote: And yes he is right CRCs hashing all have a probability of saying that the files are identical when in fact they are not. Here's the bottom line. It is either: A) Several hundred years of mathematics and cryptography are wrong. The

Re: binary file compare...

2009-04-17 Thread Tim Wintle
On Thu, 2009-04-16 at 21:44 -0700, Adam Olsen wrote: > The Wayback Machine has 150 billion pages, so 2**37. Google's index > is a bit larger at over a trillion pages, so 2**40. A little closer > than I'd like, but that's still 56294995000 to 1 odds of having > *any* collisions between *any* o

Re: binary file compare...

2009-04-17 Thread Nigel Rantor
Adam Olsen wrote: On Apr 16, 11:15 am, SpreadTooThin wrote: And yes he is right CRCs hashing all have a probability of saying that the files are identical when in fact they are not. Here's the bottom line. It is either: A) Several hundred years of mathematics and cryptography are wrong. The

Re: binary file compare...

2009-04-17 Thread Nigel Rantor
Adam Olsen wrote: On Apr 16, 4:27 pm, "Rhodri James" wrote: On Thu, 16 Apr 2009 10:44:06 +0100, Adam Olsen wrote: On Apr 16, 3:16 am, Nigel Rantor wrote: Okay, before I tell you about the empirical, real-world evidence I have could you please accept that hashes collide and that no matter ho

Re: binary file compare...

2009-04-16 Thread Adam Olsen
On Apr 16, 4:27 pm, "Rhodri James" wrote: > On Thu, 16 Apr 2009 10:44:06 +0100, Adam Olsen wrote: > > On Apr 16, 3:16 am, Nigel Rantor wrote: > >> Okay, before I tell you about the empirical, real-world evidence I have > >> could you please accept that hashes collide and that no matter how many

Re: binary file compare...

2009-04-16 Thread Adam Olsen
On Apr 16, 11:15 am, SpreadTooThin wrote: > And yes he is right CRCs hashing all have a probability of saying that > the files are identical when in fact they are not. Here's the bottom line. It is either: A) Several hundred years of mathematics and cryptography are wrong. The birthday problem

Re: binary file compare...

2009-04-16 Thread Rhodri James
On Thu, 16 Apr 2009 10:44:06 +0100, Adam Olsen wrote: On Apr 16, 3:16 am, Nigel Rantor wrote: Okay, before I tell you about the empirical, real-world evidence I have could you please accept that hashes collide and that no matter how many samples you use the probability of finding two files th

Re: binary file compare...

2009-04-16 Thread Adam Olsen
On Apr 16, 8:59 am, Grant Edwards wrote: > On 2009-04-16, Adam Olsen wrote: > > I'm afraid you will need to back up your claims with real files. > > Although MD5 is a smaller, older hash (128 bits, so you only need > > 2**64 files to find collisions), > > You don't need quite that many to have a

Re: binary file compare...

2009-04-16 Thread SpreadTooThin
On Apr 16, 3:16 am, Nigel Rantor wrote: > Adam Olsen wrote: > > On Apr 15, 12:56 pm, Nigel Rantor wrote: > >> Adam Olsen wrote: > >>> The chance of *accidentally* producing a collision, although > >>> technically possible, is so extraordinarily rare that it's completely > >>> overshadowed by the

Re: binary file compare...

2009-04-16 Thread Grant Edwards
On 2009-04-16, Adam Olsen wrote: > The chance of *accidentally* producing a collision, although > technically possible, is so extraordinarily rare that it's > completely overshadowed by the risk of a hardware or software > failure producing an incorrect result. Not when

Re: binary file compare...

2009-04-16 Thread Nigel Rantor
Adam Olsen wrote: On Apr 16, 3:16 am, Nigel Rantor wrote: Adam Olsen wrote: On Apr 15, 12:56 pm, Nigel Rantor wrote: Adam Olsen wrote: The chance of *accidentally* producing a collision, although technically possible, is so extraordinarily rare that it's completely overshadowed by the risk

Re: binary file compare...

2009-04-16 Thread Adam Olsen
On Apr 16, 3:16 am, Nigel Rantor wrote: > Adam Olsen wrote: > > On Apr 15, 12:56 pm, Nigel Rantor wrote: > >> Adam Olsen wrote: > >>> The chance of *accidentally* producing a collision, although > >>> technically possible, is so extraordinarily rare that it's completely > >>> overshadowed by the

Re: binary file compare...

2009-04-16 Thread Nigel Rantor
Adam Olsen wrote: On Apr 15, 12:56 pm, Nigel Rantor wrote: Adam Olsen wrote: The chance of *accidentally* producing a collision, although technically possible, is so extraordinarily rare that it's completely overshadowed by the risk of a hardware or software failure producing an incorrect resu

Re: binary file compare...

2009-04-16 Thread Adam Olsen
On Apr 15, 12:56 pm, Nigel Rantor wrote: > Adam Olsen wrote: > > The chance of *accidentally* producing a collision, although > > technically possible, is so extraordinarily rare that it's completely > > overshadowed by the risk of a hardware or software failure producing > > an incorrect result.

Re: binary file compare...

2009-04-15 Thread Nigel Rantor
Adam Olsen wrote: The chance of *accidentally* producing a collision, although technically possible, is so extraordinarily rare that it's completely overshadowed by the risk of a hardware or software failure producing an incorrect result. Not when you're using them to compare lots of files. Tr

Re: binary file compare...

2009-04-15 Thread Adam Olsen
On Apr 15, 11:04 am, Nigel Rantor wrote: > The fact that two md5 hashes are equal does not mean that the sources > they were generated from are equal. To do that you must still perform a > byte-by-byte comparison which is much less work for the processor than > generating an md5 or sha hash. > > I

Re: binary file compare...

2009-04-15 Thread SpreadTooThin
On Apr 15, 8:04 am, Grant Edwards wrote: > On 2009-04-15, Martin wrote: > > > > > Hi, > > > On Mon, Apr 13, 2009 at 10:03 PM, Grant Edwards wrote: > >> On 2009-04-13, SpreadTooThin wrote: > > >>> I want to compare two binary files and see if they are the same. > >>> I see the filecmp.cmp functi

Re: binary file compare...

2009-04-15 Thread Nigel Rantor
Grant Edwards wrote: We all rail against premature optimization, but using a checksum instead of a direct comparison is premature unoptimization. ;) And more than that, will provide false positives for some inputs. So, basically it's a worse-than-useless approach for determining if two files

Re: binary file compare...

2009-04-15 Thread Nigel Rantor
Martin wrote: On Wed, Apr 15, 2009 at 11:03 AM, Steven D'Aprano wrote: The checksum does look at every byte in each file. Checksumming isn't a way to avoid looking at each byte of the two files, it is a way of mapping all the bytes to a single number. My understanding of the original question

Re: binary file compare...

2009-04-15 Thread Grant Edwards
On 2009-04-15, Martin wrote: > On Wed, Apr 15, 2009 at 11:03 AM, Steven D'Aprano > I'd still say rather burn CPU cycles than development hours (if I got > the question right), _Hours_? Calling the file compare module takes _one_line_of_code_. Implementing a file compare from scratch takes abo

Re: binary file compare...

2009-04-15 Thread Grant Edwards
On 2009-04-15, Martin wrote: > Hi, > > On Mon, Apr 13, 2009 at 10:03 PM, Grant Edwards wrote: >> On 2009-04-13, SpreadTooThin wrote: >> >>> I want to compare two binary files and see if they are the same. >>> I see the filecmp.cmp function but I don't get a warm fuzzy feeling >>> that it is doin

Re: binary file compare...

2009-04-15 Thread Martin
On Wed, Apr 15, 2009 at 11:03 AM, Steven D'Aprano wrote: > The checksum does look at every byte in each file. Checksumming isn't a > way to avoid looking at each byte of the two files, it is a way of > mapping all the bytes to a single number. My understanding of the original question was a way t

Re: binary file compare...

2009-04-15 Thread Steven D'Aprano
On Wed, 15 Apr 2009 07:54:20 +0200, Martin wrote: >> Perhaps I'm being dim, but how else are you going to decide if two >> files are the same unless you compare the bytes in the files? > > I'd say checksums, just about every download relies on checksums to > verify you do have indeed the same fil

Re: binary file compare...

2009-04-14 Thread Martin
Hi, On Mon, Apr 13, 2009 at 10:03 PM, Grant Edwards wrote: > On 2009-04-13, SpreadTooThin wrote: > >> I want to compare two binary files and see if they are the same. >> I see the filecmp.cmp function but I don't get a warm fuzzy feeling >> that it is doing a byte by byte comparison of two files

Re: binary file compare...

2009-04-14 Thread Adam Olsen
On Apr 13, 8:39 pm, Grant Edwards wrote: > On 2009-04-13, Peter Otten <__pete...@web.de> wrote: > > > But there's a cache. A change of file contents may go > > undetected as long as the file stats don't change: > > Good point.  You can fool it if you force the stats to their > old values after you

Re: binary file compare...

2009-04-13 Thread Grant Edwards
On 2009-04-13, Peter Otten <__pete...@web.de> wrote: > But there's a cache. A change of file contents may go > undetected as long as the file stats don't change: Good point. You can fool it if you force the stats to their old values after you modify a file and you don't clear the cache. -- Gra

Re: binary file compare...

2009-04-13 Thread Dave Angel
SpreadTooThin wrote: On Apr 13, 2:37 pm, Grant Edwards wrote: On 2009-04-13, Grant Edwards wrote: On 2009-04-13, SpreadTooThin wrote: I want to compare two binary files and see if they are the same. I see the filecmp.cmp function but I don't get a warm fuzzy feeling that i

Re: binary file compare...

2009-04-13 Thread Steven D'Aprano
On Mon, 13 Apr 2009 15:03:32 -0500, Grant Edwards wrote: > On 2009-04-13, SpreadTooThin wrote: > >> I want to compare two binary files and see if they are the same. I see >> the filecmp.cmp function but I don't get a warm fuzzy feeling that it >> is doing a byte by byte comparison of two files t

Re: binary file compare...

2009-04-13 Thread Peter Otten
Grant Edwards wrote: > On 2009-04-13, Grant Edwards wrote: >> On 2009-04-13, SpreadTooThin wrote: >> >>> I want to compare two binary files and see if they are the same. >>> I see the filecmp.cmp function but I don't get a warm fuzzy feeling >>> that it is doing a byte by byte comparison of two

Re: binary file compare...

2009-04-13 Thread SpreadTooThin
On Apr 13, 2:37 pm, Grant Edwards wrote: > On 2009-04-13, Grant Edwards wrote: > > > > > On 2009-04-13, SpreadTooThin wrote: > > >> I want to compare two binary files and see if they are the same. > >> I see the filecmp.cmp function but I don't get a warm fuzzy feeling > >> that it is doing a by

Re: binary file compare...

2009-04-13 Thread Grant Edwards
On 2009-04-13, Grant Edwards wrote: > On 2009-04-13, SpreadTooThin wrote: > >> I want to compare two binary files and see if they are the same. >> I see the filecmp.cmp function but I don't get a warm fuzzy feeling >> that it is doing a byte by byte comparison of two files to see if they >> are t

Re: binary file compare...

2009-04-13 Thread SpreadTooThin
On Apr 13, 2:03 pm, Grant Edwards wrote: > On 2009-04-13, SpreadTooThin wrote: > > > I want to compare two binary files and see if they are the same. > > I see the filecmp.cmp function but I don't get a warm fuzzy feeling > > that it is doing a byte by byte comparison of two files to see if they

Re: binary file compare...

2009-04-13 Thread Grant Edwards
On 2009-04-13, SpreadTooThin wrote: > I want to compare two binary files and see if they are the same. > I see the filecmp.cmp function but I don't get a warm fuzzy feeling > that it is doing a byte by byte comparison of two files to see if they > are they same. Perhaps I'm being dim, but how el

Re: binary file compare...

2009-04-13 Thread SpreadTooThin
On Apr 13, 2:00 pm, Przemyslaw Kaminski wrote: > SpreadTooThin wrote: > > I want to compare two binary files and see if they are the same. > > I see the filecmp.cmp function but I don't get a warm fuzzy feeling > > that it is doing a byte by byte comparison of two files to see if they > > are they

Re: binary file compare...

2009-04-13 Thread Przemyslaw Kaminski
SpreadTooThin wrote: > I want to compare two binary files and see if they are the same. > I see the filecmp.cmp function but I don't get a warm fuzzy feeling > that it is doing a byte by byte comparison of two files to see if they > are they same. > > What should I be using if not filecmp.cmp? W

Re: binary representation of an integer

2008-06-24 Thread Terry Reedy
[EMAIL PROTECTED] wrote: On Jun 24, 10:38 am, Mark Dickinson <[EMAIL PROTECTED]> wrote: Interestingly, unlike hex and oct, bin doesn't add a trailing 'L' for longs: bin(13L) '0b1101' I wonder whether this is a bug... Strange in 2.6, but I know at least in 3.0 that all integers are C

Re: binary representation of an integer

2008-06-24 Thread bearophileHUGS
eliben: > Python's pack/unpack don't have the binary format for some reason, so > custom solutions have to be developed. One suggested in the ASPN > cookbook is:http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/111286 > However, it is very general and thus inefficient. Try mine, it may be fa

Re: binary representation of an integer

2008-06-24 Thread cokofreedom
And: # return as a string def itob_string(integer, count = 8): return "".join(str((integer >> i) & 1) for i in range(count - 1, -1, -1)) # return as an iterator (i.e [0, 0, 0, 0, 1, 0, 1, 0]) def itob_list(integer, count = 8): return [(integer >> i) & 1 for i in range(count - 1, -1, -1)]

Re: binary representation of an integer

2008-06-24 Thread cokofreedom
On Jun 24, 10:38 am, Mark Dickinson <[EMAIL PROTECTED]> wrote: > On Jun 24, 9:03 am, eliben <[EMAIL PROTECTED]> wrote: > > > What would be the quickest way to do this ? I think that for dec2bin > > conversion, using hex() and then looping with a hex->bin lookup table > > would be probably much fast

Re: binary representation of an integer

2008-06-24 Thread Nick Craig-Wood
eliben <[EMAIL PROTECTED]> wrote: > I'm interested in converting integers to a binary representation, > string. I.e. a desired function would produce: > > dec2bin(13) => "1101" > > The other way is easily done in Python with the int() function. > > Perl has a very efficient way to do dec2bi

  1   2   >