Skip to content

Commit eb74c11

Browse files
committed
Merge branch 'release/0.8.2'
# Conflicts: # setup.py
2 parents 16827c4 + 918aad5 commit eb74c11

File tree

4 files changed

+255
-24
lines changed

4 files changed

+255
-24
lines changed

.travis.yml

+16-14
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
11
language: python
22
python:
3-
- '3.5'
4-
- '3.4'
5-
- '3.3'
6-
- '3.2'
7-
- 'pypy'
8-
- '2.7'
9-
- '2.6'
10-
before_install:
11-
- sudo apt-get update -qq
12-
- sudo apt-get install -y libboost-python1.48-dev
3+
- '3.6'
4+
- '3.5'
5+
- '3.4'
6+
- '3.3'
7+
- '3.2'
8+
- 'pypy'
9+
- '2.7'
10+
- '2.6'
11+
addons:
12+
apt:
13+
packages:
14+
- libboost-python-dev
1315
install:
14-
- pip install -r requirements.txt
16+
- pip install -r requirements.txt
1517
before_script:
16-
- git submodule update --remote
18+
- git submodule update --remote
1719
script:
18-
- sudo python setup.py test
19-
- sudo python setup.py sdist bdist
20+
- sudo python setup.py test
21+
- sudo python setup.py sdist bdist
2022
deploy:
2123
- provider: pypi
2224
user: flier

pyhash.py

+226-1
Original file line numberDiff line numberDiff line change
@@ -393,9 +393,234 @@ def testErrorReturnNone(self):
393393

394394
new_refcnt = sys.getrefcount(None)
395395

396-
self.assertTrue(old_refcnt >= new_refcnt+1)
396+
self.assertTrue(old_refcnt >= new_refcnt)
397397

398398

399+
try:
400+
import pytest
401+
402+
def bench_hasher(benchmark, hasher, hash):
403+
h = hasher()
404+
data = b"".join([chr(i) for i in range(256)])
405+
406+
@benchmark
407+
def result():
408+
return h(data)
409+
410+
assert result == hash
411+
412+
@pytest.mark.benchmark(group='hash32', disable_gc=True)
413+
def test_fnv1_32(benchmark):
414+
bench_hasher(benchmark, fnv1_32, 4117514240L)
415+
416+
417+
@pytest.mark.benchmark(group='hash32', disable_gc=True)
418+
def test_fnv1a_32(benchmark):
419+
bench_hasher(benchmark, fnv1a_32, 1500862464L)
420+
421+
422+
@pytest.mark.benchmark(group='hash64', disable_gc=True)
423+
def test_fnv1_64(benchmark):
424+
bench_hasher(benchmark, fnv1_64, 487086381785722880L)
425+
426+
427+
@pytest.mark.benchmark(group='hash64', disable_gc=True)
428+
def test_fnv1a_64(benchmark):
429+
bench_hasher(benchmark, fnv1a_64, 13917847256464560128L)
430+
431+
432+
@pytest.mark.benchmark(group='hash32', disable_gc=True)
433+
def test_murmur_hash1_32(benchmark):
434+
bench_hasher(benchmark, murmur1_32, 3043957486L)
435+
436+
437+
@pytest.mark.benchmark(group='hash32', disable_gc=True)
438+
def test_murmur_hash1_aligned_32(benchmark):
439+
bench_hasher(benchmark, murmur1_aligned_32, 3043957486L)
440+
441+
442+
@pytest.mark.benchmark(group='hash32', disable_gc=True)
443+
def test_murmur_hash2_32(benchmark):
444+
bench_hasher(benchmark, murmur2_32, 2373126550L)
445+
446+
447+
@pytest.mark.benchmark(group='hash32', disable_gc=True)
448+
def test_murmur_hash2a_32(benchmark):
449+
bench_hasher(benchmark, murmur2a_32, 178525084L)
450+
451+
452+
@pytest.mark.benchmark(group='hash32', disable_gc=True)
453+
def test_murmur_hash2_aligned_32(benchmark):
454+
bench_hasher(benchmark, murmur2_aligned_32, 2373126550L)
455+
456+
457+
@pytest.mark.benchmark(group='hash32', disable_gc=True)
458+
def test_murmur_hash2_neutral_32(benchmark):
459+
bench_hasher(benchmark, murmur2_neutral_32, 2373126550L)
460+
461+
462+
@pytest.mark.benchmark(group='hash64', disable_gc=True)
463+
def test_murmur_hash2_x64_64a(benchmark):
464+
bench_hasher(benchmark, murmur2_x64_64a, 12604435678857905857L)
465+
466+
467+
@pytest.mark.benchmark(group='hash64', disable_gc=True)
468+
def test_murmur_hash2_x86_64b(benchmark):
469+
bench_hasher(benchmark, murmur2_x86_64b, 3759496224018757553L)
470+
471+
472+
@pytest.mark.benchmark(group='hash32', disable_gc=True)
473+
def test_murmur_hash3_32(benchmark):
474+
bench_hasher(benchmark, murmur3_32, 3825864278L)
475+
476+
477+
@pytest.mark.benchmark(group='hash128', disable_gc=True)
478+
def test_murmur_hash3_x86_128(benchmark):
479+
bench_hasher(benchmark, murmur3_x86_128, 97431559281111809997269275467939498127L)
480+
481+
482+
@pytest.mark.benchmark(group='hash128', disable_gc=True)
483+
def test_murmur_hash3_x64_128(benchmark):
484+
bench_hasher(benchmark, murmur3_x64_128, 149984839147466660491291446859193586361L)
485+
486+
487+
@pytest.mark.benchmark(group='hash32', disable_gc=True)
488+
def test_lookup3(benchmark):
489+
bench_hasher(benchmark, lookup3, 3792570419L)
490+
491+
492+
@pytest.mark.benchmark(group='hash32', disable_gc=True)
493+
def test_super_fast_hash(benchmark):
494+
bench_hasher(benchmark, super_fast_hash, 2804200527L)
495+
496+
497+
@pytest.mark.benchmark(group='hash32', disable_gc=True)
498+
def test_city_hash32(benchmark):
499+
bench_hasher(benchmark, city_32, 2824210825L)
500+
501+
502+
@pytest.mark.benchmark(group='hash64', disable_gc=True)
503+
def test_city_hash64(benchmark):
504+
bench_hasher(benchmark, city_64, 894299094737143437L)
505+
506+
507+
@pytest.mark.benchmark(group='hash128', disable_gc=True)
508+
def test_city_hash128(benchmark):
509+
bench_hasher(benchmark, city_128, 254849646208103091500548480943427727100L)
510+
511+
512+
@pytest.mark.benchmark(group='hash128', disable_gc=True)
513+
def test_city_hash_crc128(benchmark):
514+
bench_hasher(benchmark, city_crc_128, 254849646208103091500548480943427727100L)
515+
516+
517+
@pytest.mark.benchmark(group='hash32', disable_gc=True)
518+
def test_spooky_hash32(benchmark):
519+
bench_hasher(benchmark, spooky_32, 2489700128L)
520+
521+
522+
@pytest.mark.benchmark(group='hash64', disable_gc=True)
523+
def test_spooky_hash64(benchmark):
524+
bench_hasher(benchmark, spooky_64, 8714752859576848160L)
525+
526+
527+
@pytest.mark.benchmark(group='hash128', disable_gc=True)
528+
def test_spooky_hash128(benchmark):
529+
bench_hasher(benchmark, spooky_128, 69975394272542483818884528997491134240L)
530+
531+
532+
@pytest.mark.benchmark(group='hash32', disable_gc=True)
533+
def test_farm_hash32(benchmark):
534+
bench_hasher(benchmark, farm_32, 3977123615L)
535+
536+
537+
@pytest.mark.benchmark(group='hash64', disable_gc=True)
538+
def test_farm_hash64(benchmark):
539+
bench_hasher(benchmark, farm_64, 5291657088564336415L)
540+
541+
542+
@pytest.mark.benchmark(group='hash128', disable_gc=True)
543+
def test_farm_hash128(benchmark):
544+
bench_hasher(benchmark, farm_128, 2614362402971166945389138950146702896L)
545+
546+
547+
@pytest.mark.benchmark(group='hash64', disable_gc=True)
548+
def test_metro_hash64_1(benchmark):
549+
bench_hasher(benchmark, metro_64_1, 6897098198286496634L)
550+
551+
552+
@pytest.mark.benchmark(group='hash128', disable_gc=True)
553+
def test_metro_hash128_1(benchmark):
554+
bench_hasher(benchmark, metro_128_1, 284089860902754045805586152203438670446L)
555+
556+
557+
@pytest.mark.benchmark(group='hash64', disable_gc=True)
558+
def test_metro_hash64_2(benchmark):
559+
bench_hasher(benchmark, metro_64_2, 9928248983045338067L)
560+
561+
562+
@pytest.mark.benchmark(group='hash128', disable_gc=True)
563+
def test_metro_hash128_2(benchmark):
564+
bench_hasher(benchmark, metro_128_2, 298961466275459716490100873977629041349L)
565+
566+
567+
@pytest.mark.benchmark(group='hash64', disable_gc=True)
568+
def test_metro_hash_crc64_1(benchmark):
569+
bench_hasher(benchmark, metro_crc_64_1, 15625740387403976237L)
570+
571+
572+
@pytest.mark.benchmark(group='hash128', disable_gc=True)
573+
def test_metro_hash_crc128_1(benchmark):
574+
bench_hasher(benchmark, metro_crc_128_1, 221795002586229010982769362009963170208L)
575+
576+
577+
@pytest.mark.benchmark(group='hash64', disable_gc=True)
578+
def test_metro_hash_crc64_2(benchmark):
579+
bench_hasher(benchmark, metro_crc_64_2, 9313388757605283934L)
580+
581+
582+
@pytest.mark.benchmark(group='hash128', disable_gc=True)
583+
def test_metro_hash_crc128_2(benchmark):
584+
bench_hasher(benchmark, metro_crc_128_2, 319940271611864595969873671463832146628L)
585+
586+
587+
@pytest.mark.benchmark(group='hash64', disable_gc=True)
588+
def test_mum_hash3(benchmark):
589+
bench_hasher(benchmark, mum_64, 5704960907050105809L)
590+
591+
592+
@pytest.mark.benchmark(group='hash32', disable_gc=True)
593+
def test_t1hash32(benchmark):
594+
bench_hasher(benchmark, t1_32, 677439739L)
595+
596+
597+
@pytest.mark.benchmark(group='hash32', disable_gc=True)
598+
def test_t1hash32be(benchmark):
599+
bench_hasher(benchmark, t1_32_be, 967014975L)
600+
601+
602+
@pytest.mark.benchmark(group='hash64', disable_gc=True)
603+
def test_t1hash64(benchmark):
604+
bench_hasher(benchmark, t1_64, 6501324028002495964L)
605+
606+
607+
@pytest.mark.benchmark(group='hash64', disable_gc=True)
608+
def test_t1hash64be(benchmark):
609+
bench_hasher(benchmark, t1_64_be, 6501324028002495964L)
610+
611+
612+
@pytest.mark.benchmark(group='hash32', disable_gc=True)
613+
def test_xx_hash32(benchmark):
614+
bench_hasher(benchmark, xx_32, 1497633363L)
615+
616+
617+
@pytest.mark.benchmark(group='hash64', disable_gc=True)
618+
def test_xx_hash64(benchmark):
619+
bench_hasher(benchmark, xx_64, 2282408585429094475L)
620+
621+
except ImportError:
622+
pass
623+
399624
if __name__ == '__main__':
400625
if "-v" in sys.argv:
401626
level = logging.DEBUG

requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pytest-benchmark >= 3.1

setup.py

+12-9
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@
6060
]
6161

6262
extra_compile_args += ["/O2", "/GL", "/MT", "/EHsc", "/Gy", "/Zi"]
63-
extra_link_args += ["/DLL", "/OPT:REF", "/OPT:ICF", "/MACHINE:X64" if is_64bit else "/MACHINE:X86"]
63+
extra_link_args += ["/DLL", "/OPT:REF", "/OPT:ICF",
64+
"/MACHINE:X64" if is_64bit else "/MACHINE:X86"]
6465
elif os.name == "posix" and sys.platform == "darwin":
6566
is_64bit = math.trunc(math.ceil(math.log(sys.maxsize, 2)) + 1) == 64
6667
include_dirs += [
@@ -70,15 +71,17 @@
7071
libraries += ["boost_python-mt"]
7172
extra_compile_args += ["-msse4.2", "-maes"]
7273
elif os.name == "posix":
73-
libraries += ["boost_python", "rt", "gcc"]
74-
extra_compile_args += ["-msse4.2", "-maes"]
74+
import platform
7575

76-
if os.getenv('TRAVIS') == 'true':
77-
print("force to link boost::python base on Python v%d.%d" % (sys.version_info.major, sys.version_info.minor))
76+
libraries += ["rt", "gcc"]
7877

79-
os.remove('/usr/lib/libboost_python.so')
80-
os.symlink('/usr/lib/libboost_python-py%d%d.so' % (sys.version_info.major, sys.version_info.minor),
81-
'/usr/lib/libboost_python.so')
78+
if platform.dist()[0] == "Ubuntu":
79+
libraries += ["boost_python-py%d%d" % (sys.version_info.major,
80+
sys.version_info.minor)]
81+
else:
82+
libraries += ["boost_python"]
83+
84+
extra_compile_args += ["-msse4.2", "-maes"]
8285

8386
pyhash = Extension(name="_pyhash",
8487
sources=source_files,
@@ -91,7 +94,7 @@
9194
)
9295

9396
setup(name='pyhash',
94-
version='0.8.1',
97+
version='0.8.2',
9598
description='Python Non-cryptographic Hash Library',
9699
long_description="a python non-cryptographic hash library",
97100
url='https://github.com/flier/pyfasthash',

0 commit comments

Comments
 (0)