Anyway, this approach is not suitable for the fast generation of addresses because in order to calculate a million of bitcoin addresses, you need to create the same number of instances of PrivateKey class, which is an extremely inefficient way and consumes too much computer memory.
you don't have to store them you just have to store one at a time. so there are no memory requirements.
And after conducting a small test where I try to calculate just 10000 addresses without printing them or writing them to a file, I can conclude that it is a very slow method.
what's faster?
It took more than 4 seconds on my laptop to perform 10000 calculations (private-public-address).
how long does it take your laptop to generate 10000 legacy addresses? in my small test, I find that generating legacy addresses using the bit package is about twice as fast as generating bech32 ones.
Number of addresses processed:
1000
Bech32 addresses only
Total conversion time:
0.8630490303039551
Number of addresses processed:
1000
COMPRESSED addresses only
Total conversion time:
0.4350249767303467
Uncompressed addresses only followed a similar time. So I'd say based on this I'd say that if bit is considered fast and efficient method of generating legacy addresses, then it probably is about the fastest way for bech32 also. and if what you say is true that bech32 is more cpu intensive then you probably can't do any better.