Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #26106

Re: Generating valid identifiers

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <gandalf@shopzeus.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.044
X-Spam-Evidence '*H*': 0.92; '*S*': 0.00; 'modified': 0.05; 'one?': 0.05; 'that?': 0.05; '(of': 0.07; 'identifier': 0.09; 'identifier,': 0.09; 'part,': 0.09; 'truncate': 0.09; 'recognizing': 0.16; 'truncating': 0.16; 'value.)': 0.16; 'value:': 0.16; '(or': 0.18; 'question.': 0.20; 'somebody': 0.23; 'least': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User- Agent:1': 0.26; '(since': 0.29; 'hash': 0.29; 'goes': 0.33; 'problem': 0.33; 'to:addr:python-list': 0.33; 'bigger': 0.35; 'problem,': 0.35; 'received:192.168.0': 0.35; 'should': 0.36; 'thank': 0.36; 'bad': 0.37; 'two': 0.37; 'rather': 0.37; 'subject:: ': 0.38; 'instead': 0.39; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'received:192.168': 0.40; 'think': 0.40; 'most': 0.61; 'you.': 0.61; 'chance': 0.61; 'received:62': 0.62; 'different': 0.63; 'algorithm,': 0.84; 'received:192.168.0.101': 0.84; 'received:192.168.13': 0.84; 'received:192.168.13.238': 0.84; 'received:62.179': 0.84; 'received:62.179.121': 0.84; 'received:edge03.upcmail.net': 0.84; 'received:upcmail.net': 0.84; 'luck': 0.93
X-SourceIP 89.134.225.226
Date Thu, 26 Jul 2012 20:08:59 +0200
From Laszlo Nagy <gandalf@shopzeus.com>
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:14.0) Gecko/20120713 Thunderbird/14.0
MIME-Version 1.0
To python-list@python.org
Subject Re: Generating valid identifiers
References <mailman.2604.1343305588.4697.python-list@python.org> <50116281$0$29978$c3e8da3$5496439d@news.astraweb.com>
In-Reply-To <50116281$0$29978$c3e8da3$5496439d@news.astraweb.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2621.1343326154.4697.python-list@python.org> (permalink)
Lines 34
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1343326154 news.xs4all.nl 6955 [2001:888:2000:d::a6]:58023
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:26106

Show key headers only | View raw


>> * Would it be a problem to use CRC32 instead of SHA? (Since security is
>> not a problem, and CRC32 is faster.)
> 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).
Yes, that was the question. How do I avoid that? (Of course I can avoid 
that by using a full sha256 hash value.)
>> * Can somebody think of a
>> better algorithm, that would give a bigger chance of recognizing the
>> original identifier from the modified one?
> Rather than truncating the most significant part of the identifier, the
> field name, you should truncate the least important part, the middle.
>
> a.b.c.d.e.f.g.something
>
> goes to:
>
> a.b...g.something
>
> or similar.
Yes, this is a good idea. Thank you.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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