pbrady/fastcache — pull request #20 by pbrady (2014-08-29 20:58:43+00:00)
Title: Optimize comparison by checking pointers

Only call PyObject_RichCompareBool if the pointers differ (essentially an `is` shortcut)

* On Master
```bash
$ ipython
Python 3.4.1 |Continuum Analytics, Inc.| (default, May 19 2014, 13:02:41)
Type "copyright", "credits" or "license" for more information.

IPython 2.2.0 -- An enhanced Interactive Python.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://binstar.org
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.

In [1]: from fastcache import benchmark

In [2]: benchmark.run()
Test Suite 1 :

Primarily tests cost of function call, hashing and cache hits.
Benchmark script based on
http://bugs.python.org/file28400/lru_cache_bench.py

function call speed up
untyped(i) 10.90, typed(i) 28.49
untyped("spam", i) 16.03, typed("spam", i) 25.29
untyped("spam", "spam", i) 14.57, typed("spam", "spam", i) 21.40
untyped(a=i) 11.70, typed(a=i) 19.50
untyped(a="spam", b=i) 9.85, typed(a="spam", b=i) 15.50
untyped(a="spam", b="spam", c=i) 8.95, typed(a="spam", b="spam", c=i) 14.05

min mean max
untyped 8.951 12.000 16.029
typed 14.048 20.705 28.493

Test Suite 2 :

Tests millions of misses and millions of hits to quantify
cache behavior when cache is full.

function call speed up
untyped(i, j, a="spammy") 7.98, typed(i, j, a="spammy") 11.50

In [3]:
```

* PR
```bash
$ ipython
Python 3.4.1 |Continuum Analytics, Inc.| (default, May 19 2014, 13:02:41)
Type "copyright", "credits" or "license" for more information.

IPython 2.2.0 -- An enhanced Interactive Python.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://binstar.org
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.

In [1]: from fastcache import benchmark

In [2]: benchmark.run()
Test Suite 1 :

Primarily tests cost of function call, hashing and cache hits.
Benchmark script based on
http://bugs.python.org/file28400/lru_cache_bench.py

function call speed up
untyped(i) 11.09, typed(i) 29.26
untyped("spam", i) 17.72, typed("spam", i) 26.77
untyped("spam", "spam", i) 15.60, typed("spam", "spam", i) 21.46
untyped(a=i) 13.36, typed(a=i) 20.14
untyped(a="spam", b=i) 10.92, typed(a="spam", b=i) 16.57
untyped(a="spam", b="spam", c=i) 9.22, typed(a="spam", b="spam", c=i) 14.23

min mean max
untyped 9.220 12.984 17.722
typed 14.231 21.405 29.257

Test Suite 2 :

Tests millions of misses and millions of hits to quantify
cache behavior when cache is full.

function call speed up
untyped(i, j, a="spammy") 8.04, typed(i, j, a="spammy") 11.86

In [3]:
```