`for` loops in python, combined with instance methods such as `.append()` can be a little slow, so I wonder if this might be speeded up a bit using two or three list comprehensions instead?

The first element of `xarray` looks to be `xmin`, so the probability list could be setup using

    probability = [function(xval) for xval in xarray]

This will be faster since the python intepreter isn't checking and rechecking things redundantly for every pass through the for loop.  `dcdf` is slightly tricksier, but I think

    dcdf = [galsim.integ.int1d(function, xarray[i], xarray[i+1]) for i in range(npoints - 1)]

would achieve the same result and should be faster, but there may even be a faster way than that (perhaps using `zip()`... Or not).  Finally

    cdf = [sum(dcdf.insert(0, 0.)[0:i+1]) for i in range(npoints)]

should work, although again worth checking that I've got the indices right and correctly inserted the desired `[0.,]` entry at the start of `cdf`.  It's a little esoteric this python list stuff, but if you get sad enough like me you might even start to find it fun...