Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #26110
| References | <mailman.2604.1343305588.4697.python-list@python.org> <50116281$0$29978$c3e8da3$5496439d@news.astraweb.com> |
|---|---|
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | 2012-07-26 13:28 -0600 |
| Subject | Re: Generating valid identifiers |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2628.1343330939.4697.python-list@python.org> (permalink) |
On Thu, Jul 26, 2012 at 9:30 AM, Steven D'Aprano <steve+comp.lang.python@pearwood.info> wrote: > What happens if you get a collision? > > That is, you have two different long identifiers: > > a.b.c.d...something > a.b.c.d...anotherthing > > which by bad luck both hash to the same value: > > a.b.c.d.$AABB99 > a.b.c.d.$AABB99 > > (or whatever). The odds of a given pair of identifiers having the same digest to 10 hex digits are 1 in 16^10, or approximately 1 in a trillion. If you bought one lottery ticket a day at those odds, you would win approximately once every 3 billion years. But it's not enough just to have a hash collision, they also have to match exactly in the first 21 (or 30, or whatever) characters of their actual names, and they have to both be long enough to invoke the truncating scheme in the first place. The Oracle backend for Django uses this same approach with an MD5 sum to ensure that identifiers will be no more than 30 characters long (a hard limit imposed by Oracle). It actually truncates the hash to 4 digits, though, not 10. This hasn't caused any problems that I'm aware of.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Generating valid identifiers Laszlo Nagy <gandalf@shopzeus.com> - 2012-07-26 14:26 +0200
Re: Generating valid identifiers Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-26 15:30 +0000
Re: Generating valid identifiers Laszlo Nagy <gandalf@shopzeus.com> - 2012-07-26 20:08 +0200
Re: Generating valid identifiers Ian Kelly <ian.g.kelly@gmail.com> - 2012-07-26 13:28 -0600
Re: Generating valid identifiers Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-27 01:54 +0000
Re: Generating valid identifiers Laszlo Nagy <gandalf@shopzeus.com> - 2012-07-27 09:34 +0200
Re: Generating valid identifiers Ian Kelly <ian.g.kelly@gmail.com> - 2012-07-26 14:00 -0600
Re: Generating valid identifiers Laszlo Nagy <gandalf@shopzeus.com> - 2012-07-27 09:28 +0200
Re: Generating valid identifiers Laszlo Nagy <gandalf@shopzeus.com> - 2012-07-27 11:59 +0200
csiph-web