Created
November 14, 2015 00:57
-
-
Save geekdinazor/c37226c6a6ba4f8a225d to your computer and use it in GitHub Desktop.
Pypy için son derece hızlı rastgele ve benzersiz TC Kimlik no üretme betiği.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from random import randint | |
def rastgele_tc(): #http://basarancaner.blogspot.com.tr/2011/01/rastgele-tc-kimlik-no-uretici.html | |
tcno = str(randint(100000000, 1000000000)) | |
list_tc = map(int, tcno) | |
tc10 = (sum(list_tc[::2]) * 7 - sum(list_tc[1::2])) % 10 | |
return tcno + str(tc10) + str((sum(list_tc[:9]) + tc10) % 10) | |
dizi = set() | |
while(len(dizi) <= 100000): | |
dizi.add(rastgele_tc()) | |
f = open('dump.txt', 'w') | |
for i in dizi: | |
f.write(i + "\n") | |
# Test Makinası: | |
# CPU: Intel(R) Celeron(R) CPU N2840 @ 2.16GHz | |
# RAM: 4GB | |
# OS: Xubuntu 15.04 32 Bit | |
# Pypy version: PyPy 2.5.0 with GCC 4.9.2 | |
# Benchmark sonuçları (time) | |
# real 0m40.326s | |
# user 0m38.580s | |
# sys 0m1.780s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment