I am surprised D is slower than Python, but I am not surprised that Python is not slow. At least in this case, most of the work is likely in native code in both cases.