def curve_weights(degree, s):
    """Compute de Casteljau weights for a curve.

    .. note::

       This function could be optimized by introducing a cache. However, any
       code using SymPy is (for now) assumed not to be performance critical.

    Args:
        degree (int): The degree of a curve.
        s (sympy.Symbol): The symbol to be used in the weights.

    Returns:
        sympy.Matrix: The de Casteljau weights for the curve as a
        ``(degree + 1) x 1`` matrix.
    """
    # NOTE: We import SymPy at runtime to avoid the import-time cost for users
    #       that don't want to do symbolic computation. The ``sympy`` import is
    #       a tad expensive.
    import sympy  # pylint: disable=import-outside-toplevel

    return sympy.Matrix(
        [
            [sympy.binomial(degree, k) * s**k * (1 - s) ** (degree - k)]
            for k in range(degree + 1)
        ]
    )