A Python equivalent of the unbiased xcorr Matlab function

I have searched but not found a python implementation that is reasonably equivalent to the unbiased xcorr Matlab function.

This is my best solution so far:

import numpy as np

def xcorr(x, y=None):
    """Correlation like Matlab's xcorr (unbiased)"""
    if y is None:
        # perform auto-correlation
        y = x
    N = max(len(x), len(y))
    z = np.correlate(x, y, mode='full')
    s = 1 / (N - np.arange(N-1))
    z[N:] *= s
    if N % 2 == 0:
        z[N-1] /= N
    z[:N-1] *= np.flip(s)
    return z

Let me know if you have something better!