very annoyed with this slow bit of code that i can't make run faster. somehow i can do thousands of nearest neighbors lookups per second but can't construct an array of coordinates for a few hundred character glyphs without it taking 250ms, this is probably why people use c++ and stuff huh
@wrenpile tried it both ways and it didn't help. i suspect the problem is that python is making a copy of the data somewhere that i can't see
@enkiv2 @wrenpile i was doing it with numpy arrays but they don't seem to be designed for this use case or something? huge slowdowns from unintuitive things (like incrementing a value at an index is slow compared to constructing an empty array with zeros except for a value at that index and adding the two arrays together?!)
@aparrish @wrenpile
Python is particularly bad about having predictable performance even compared to other interpreted languages.
(Like, pypy -- a python interpreter written in python -- is faster than regular python, simply because they reimplemented common-but-slow structures in terms of fast-but-long equivalent structures. Because of shit like huge performance differences between 2*2, 2+2, and 2>>1 that don't fall the way a C programmer would expect.)
@aparrish each high level language has a separate bag of tricks to made code faster (or rather, a different set of pitfalls that makes code slower), but one thing that often helps is reducing the number of allocations (like trying to get rid of temporary lists, even if it means reusing objects in ugly ways)
@hisham_hm you are describing my life for the past like 72 hrs. everything i've tried in that vein gives me like a 1% speed up so i suspect there's a big allocation happening somewhere that i just don't know about yet
@aparrish I don't know what language you're doing this in, but I hope it's one for which a profiler is available! if so that could help solve the mystery
@aparrish just wondering is some unicode parsing happening somewhere in a tight loop maybe? just trying to help... 😀
@aparrish Are you building the array one cell at a time or allocating it en bloc and then filling in the data?
Because the latter might be faster.
But maybe you already thought of that…