Re: 16bit hash

2007-06-29 Thread Paul Rubin
Robin Becker <[EMAIL PROTECTED]> writes: > whether it's any better than using the lowest bits I have no real > idea. I suppose (sha being flavour of the month) I should really use I think if you have more than a few fonts you really have to assign the id's uniquely instead of using hashes, to avoi

Re: 16bit hash

2007-06-28 Thread Martin v. Löwis
> If the UniqueID is used it must be unique when used in the printer > (where I cannot control which other UniqueID's might be present). I don't know much about PostScript; googling around gives http://fontforge.sourceforge.net/UniqueID.html that says that you should not use them anymore, and h

Re: 16bit hash

2007-06-28 Thread Robin Becker
Martin v. Löwis wrote: .. >> ie a bunch of lists of strings which are eventually joined together and >> written out with a template to make the postscript definition. > > And the UniqueID should be unique within this file, right? > > Why don't you just use a serial number then? .. I d

Re: 16bit hash

2007-06-28 Thread Martin v. Löwis
> I'm trying to create UniqueID's for dynamic postscript fonts. According > to my resources we don't actually need to use these, but if they are > required by a particular postscript program (perhaps to make a print run > efficient) then the private range of these ID's is 400<=UID<=499 > ie

Re: 16bit hash

2007-06-28 Thread Robin Becker
Thomas Jollans wrote: > Robin Becker wrote: ... >> I'm not sure my postscript is really good enough to do the latter so I >> hoped to pursue a python based approach which has a low probability of >> busting. Originally I thought the range was a 16bit number which is why >> I started with 16bit

Re: 16bit hash

2007-06-28 Thread Thomas Jollans
Robin Becker wrote: > Martin v. Löwis wrote: > > 0 the ideal hash > > :) > > can't be argued with > >> ... >> So: what are your input data, and what is the >> distribution among them? >> >> Regards, >> Martin >> > I'm trying to create UniqueID's for dynamic postscript fonts. According > to

Re: 16bit hash

2007-06-28 Thread Robin Becker
Martin v. Löwis wrote: 0 the ideal hash :) can't be argued with >... > So: what are your input data, and what is the > distribution among them? > > Regards, > Martin > I'm trying to create UniqueID's for dynamic postscript fonts. According to my resources we don't actually need to use th

Re: 16bit hash

2007-06-27 Thread Paul Rubin
"Martin v. Löwis" <[EMAIL PROTECTED]> writes: > So: what are your input data, and what is the > distribution among them? With good enough hash functions one shouldn't need to care about the input distribution. Basically functions like SHA can be used as extractors: http://en.wikipedia.org/wik

Re: 16bit hash

2007-06-27 Thread Martin v. Löwis
> Is the any way to get an efficient 16bit hash in python? Unfortunately, that problem is underspecified. The simplest and most efficient 16-bit hash I can come up with is def super_efficient_hash(o): return 0 Now, you say: this gives collisions. So yes, it does - but you didn't ask for it to

Re: 16bit hash

2007-06-27 Thread Paul Rubin
Robin Becker <[EMAIL PROTECTED]> writes: > >> Is the any way to get an efficient 16bit hash in python? > > hash(obj)&65535 > > - Josiah > yes I thought of that, but cannot figure out if the internal hash > really distributes the bits evenly. Particularly since it seems to > treat integers etc as

Re: 16bit hash

2007-06-27 Thread Dan Bishop
On Jun 27, 12:11 pm, Robin Becker <[EMAIL PROTECTED]> wrote: > Josiah Carlson wrote: > > Robin Becker wrote: > >> Is the any way to get an efficient 16bit hash in python? > > > hash(obj)&65535 > > > - Josiah > > yes I thought of that, but cannot figure out if the internal hash really > distribute

Re: 16bit hash

2007-06-27 Thread Jon Ribbens
On 2007-06-27, Robin Becker <[EMAIL PROTECTED]> wrote: > Is the any way to get an efficient 16bit hash in python? int(md5.new(s).hexdigest()[:4], 16) ? -- http://mail.python.org/mailman/listinfo/python-list

Re: 16bit hash

2007-06-27 Thread Thomas Heller
Robin Becker schrieb: > Josiah Carlson wrote: >> Robin Becker wrote: >>> Is the any way to get an efficient 16bit hash in python? >> >> hash(obj)&65535 >> >> - Josiah > yes I thought of that, but cannot figure out if the internal hash really > distributes the bits evenly. Particularly since it

Re: 16bit hash

2007-06-27 Thread Nick Craig-Wood
Robin Becker <[EMAIL PROTECTED]> wrote: > Is the any way to get an efficient 16bit hash in python? Here is a 32 bit crc of which you could use the bottom 16 bits as a 16 bit hash... >>> import binascii >>> binascii.crc32("hello world") 222957957 >>> crc = binascii.crc32("hello") >>> cr

Re: 16bit hash

2007-06-27 Thread Robin Becker
Josiah Carlson wrote: > Robin Becker wrote: >> Is the any way to get an efficient 16bit hash in python? > > hash(obj)&65535 > > - Josiah yes I thought of that, but cannot figure out if the internal hash really distributes the bits evenly. Particularly since it seems to treat integers etc as s

Re: 16bit hash

2007-06-27 Thread Josiah Carlson
Robin Becker wrote: > Is the any way to get an efficient 16bit hash in python? hash(obj)&65535 - Josiah -- http://mail.python.org/mailman/listinfo/python-list