4 ms·
Fun, I learned something today! I imagine the performance of proxies is pretty terrible, so this is just a toy - but it could come in handy for implementing equ
by aoeusnth1 8y ago
Fun, I learned something today! I imagine the performance of proxies is pretty terrible, so this is just a toy - but it could come in handy for implementing equivalents of some of the nice syntax sugar that numpy and tensorflow have in JavaScript.
- olliej 8y agoProxies aren’t actually that slow, the problem is the committee refusal to acknowledge indexed properties as being something that actually exists. The result is that all property names passed to the interceptor get converting to a string. That means if for example you were intending to proxy an array, your performance is destroyed. First a numeric index gets converted to a string, then when to pass that on to your target array it has to be parsed back into a number. In a trivial case (literally just forwarding the access) it might be possible to fake the stringing of the property name, but if you actually end up doing real work it becomes increasingly hard to avoid the property name escaping and so having to be reified.