BUG: Error checks for the dtype shape.

Also creates a clean tuple for the shape tuple, instead of
passing potentially mutable objects through.

Closes gh-4009
ENH: Type specific binary search functions for `searchsorted`

This PR replaces the generic binary search functions used by `searchsorted`
with type specific ones for numeric types. This results in a speed-up of
calls to `searchsorted` which is highly dependent on the size of the
'haystack' and the 'needle', with typical values for large enough needles
in the 1.5x - 3.0x for direct searches (i.e. without a `sorter` argument)
and 1.2x - 2.0x for indirect searches. A summary benchmark on float and
int arrays can be found [here](https://gist.github.com/jaimefrio/8704101).

Furthermore, the type specific binary search functions can take strided
inputs for all their arguments, which is a step in the right direction to
eventually add an `axis` argument to `searchsorted`.
BUG: check for monotonic bin arrays in digitize

The check for monotonic bin arrays of digitize doesn't properly handle
inputs with repeated entries at the beginning of the array:

```
>>> np.__version__
'1.8.0'
>>> np.digitize([1], [0, 0 , 2])
array([2], dtype=int64)
>>> np.digitize([1], [2, 2, 0])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: The bins must be monotonically increasing or decreasing
```

Modified `check_array_monotonic` in `_compiled_base.c` to skip over repeating
entries before deciding to check for increasing or decreasing monotonicity
and added relevant tests to `test_function_base.py`.
- Modified resetting of binary search indices when multiple keys are being
  searched, following @juliantaylor's suggestion. This speeds up searches of
  ordered keys by a lot (up to 3x), but slightly slows down purely random
  keys. Some benchmarks are available [here](https://gist.github.com/jaimefrio/8704101#file-gistfile2-txt)
- Added tests for proper handling of the smart index resetting when the last
  key was larger than all items in the searched array.
- Added basic tests for all implemented dtypes.
- This last change unearthed a funny behavior of `PyArray_CheckFromAny`,
  which was changing the byteorder attribute of `NPY_UBYTE` from `NPY_IGNORE`
  to `NPY_NATIVE`, and triggering lots of failures in `np.core.test()`. So I
  modified `PyArray_CheckFromAny` to leave `NPY_IGNORE` byteorders alone.
- Removed the now unused binary search functions from `item_selection.c`.
- Modified generic searches to take a PyArrayObject and use its PyArray_DESCR
  to fetch a compare function, rather than the global state function that
  the sort functions take.
- Added get_genericbinsearch_func and get_genericargbinsearch_func to
  npy_binsearch.h.src, to get a function pointer to the right generic type
  search function. This makes the code in item_selection.c easier to follow,
  I think.
- Littered PyArray_SearchSorted with comments with my ref counts for dtype,
  hopefully I got it right this time.
- Refactored code, to have type specific and generic binary search functions
  share signature. `get_(arg)binsearch_func` now handles finding the right
  function for all cases, making it transparent to `PyArray_SearchSorted`.
- Reordered types in `(arg)binsearch_map` to be sorted by type num. Since
  the function is searched using binary search, this is a requirement. Only
  `npy_half` was out of place. Added comment to remind future expansions.
- Corrected reference counting for `dtype` in `PyArray_SearchSorted`.
- The requirement for a coniguous `sorter` array had been dropped, but the
  stride for it was set to the element size. This created an opportunity for
  a very unlikely bug, that is now corrected. Added test to verify it.
- Removed unused includes from `binsearch.c.src` and `npy_binsearch.h.src`.
- initialize `last_key_val` to first value in `key` to avoid compiler warnings.
- removed unused `store_arr` variable from `PyArray_SearchSorted`.
STY: adapted code to `C_STYLE_GUIDE.rst.txt`
STY: adapted code to `C_STYLE_GUIDE.rst.txt`.
MAINT: rewrote `check_array_monotonic` to use array indices, not pointers.
TST: tests for proper handling of bins with all items almost equal now check
     the return value for correctness, not just that an error is not raised.
BUG: Fix mean, var, std methods for object arrays.

This takes care to preserve the object type for scalar returns and
fixes the error that resulted when the scalar did not have a dtype
attribute.

Closes #4063.
MAINT: Remove checks for presence of decimal module.

The decimal module has been available since Python 2.4 and we no
longer support Python earlier than 2.6.
ENH: add tobytes and stop using tostring in documentation

tostring returns bytes which are not equal to string, so provide a
tobytes function alias.
tostring does not emit a deprecation warning yet so rdepends do not need
to check two names to support older versions of numpy without warnings.
Merge pull request #4276 from charris/fix-stat-methods

BUG: Fix mean, var, std methods for object arrays.
MAINT: hide symbols that shouldn't be exported
MAINT: rewrote `check_array_monotonic` following @charris suggestion to
       minimize indexing.
Merge pull request #4247 from jaimefrio/digitize-monotonic

BUG: check for monotonic bin arrays in digitize
Merge pull request #4279 from juliantaylor/symbol-cleanup

MAINT: hide symbols that shouldn't be exported
MAINT: Added `NPY_VISIBILITY_HIDDEN` to binary search functions in
       `binsearch.c.src` and `npy_binsearch.h.src`.
ENH: single pass over array in `bincount` to determine output size
`bincount` checks its input array to make sure there are no negative entries,
and to determine the size of the output array. This is done by calling two
different functions, each having to loop over the whole array. This PR
adds a new function, `minmax`, that computes the minimum and maximum of the
array in a single pass over it. This leads to speed-ups peaking at 1.5x,
with typical values for large arrays around 1.15x - 1.25x.

A full benchmark summary of the new implementation, including a supposedly
more efficient algorithm that turned out to run slower, can be found [here](https://gist.github.com/jaimefrio/8743836).