Closed kolomenkin closed 4 years ago
base58 is not advisable on big strings to begin with but I'm not opposed to performance improvements. PRs are welcome especially if they include benchmark numbers! :)
Regrading pre-calculating I think the easiest solution is to stick this in a function like get_map with @lru_cache because the alphabet can be user specified.
Please look into this draft PR: https://github.com/keis/base58/pull/53
The following code has very bad performance for long encoded strings:
It is better to use pre-calculated array to map any possible character to its index in original alphabet.
Original code:
Possible solution:
My solution is not ideal for short strings. It is a good idea to have mapping to be pre-calculated for each alphabet. And original solution was raising exception in case of unexpected character found. New solution will not raise exception but it may be fixed.