Are fuzzy data structures and dynamic languages ​​effective?

I recently read about caching data structures, such as auxiliary buffer heaps. These data structures work by storing their most recently accessed items in the cache, so any subsequent access is also faster.

Most of these data structures are implemented using a low-level language such as C / C ++. Should I try to transfer these data structures to a dynamic language such as Python, or does the overhead of working in a virtual machine destroy all the advantages of these data structures? This seems like the last, but I thought I'd ask to see if anyone really had experience.

+3
source share
2 answers

In C (or C ++), you have fine-grained control over the exact size of each data structure. You also have the option of small-scale memory management. In the end, you can extend the method new, use it mallocdirectly, and otherwise structure the memory to create spatial locality.

In most dynamic languages ​​(like Python), you have no control over the exact size of anything, much less its location.

In Python, you may have temporary locality, but you have little or no spatial locality.

memoization . , , memoization ( ) .

, C ++ , , . memoization .

http://wiki.python.org/moin/PythonDecoratorLibrary#Memoize

+2

, ( ), . - "" . (: ).

, VM , , . , , , .

, VM . , - 4 ( 3 ). , .

"", , .

+1

Source: https://habr.com/ru/post/1729566/


All Articles