1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Generate ID from string in Python

Discussão em 'Python' iniciado por Stack, Setembro 8, 2025.

  1. Stack

    Stack Membro Participativo

    I'm struggling a bit to generate ID of type integer for given string in Python.

    I thought the built-it hash function is perfect but it appears that the IDs are too long sometimes. It's a problem since I'm limited to 64bits as maximum length.

    My code so far: hash(s) % 10000000000. The input string(s) which I can expect will be in range of 12-512 chars long.

    Requirements are:

    • integers only
    • generated from provided string
    • ideally up to 10-12 chars long (I'll have ~5 million items only)
    • low probability of collision..?

    I would be glad if someone can provide any tips / solutions.

    Continue reading...

Compartilhe esta Página