My guess it is all of the string converting back and forth to character arrays.
https://gist.github.com/rookie/3d9a848c6fefacc4254da921da79b...
It now runs faster (when compiled, optimized) than the python code.
xcrun -sdk macosx swiftc -O gen.swift