We haven’t been able to get up to 6.664KHz using python, we think it is too slow.
Using C, we were able to get up to 5.2KHz on a Raspberry Pi 3, and this was while doing other stuff in between. You might be able to get it running at 6.664Khz with C on a Pi 4 and using the optimisation flag.
BTW:An Arduino has no problem getting it to run at full speed.
Richard --OzzMaker.com --