On Tue, 24 Apr 2001 22:58:07 GMT, Courageous <jkraska1 at san.rr.com> wrote: > >>Another concept I introduced is the "solidification" of a function. >>Certain globals and module contents can be marked as "solid", and loads >>of them will be hoisted into constant loads. Typically, builtins like >>'range', the 'math' module, and its contents would be marked as "solid". > > You did this primarily to reduce function call overhead in some contexts, > yes? What if it were possible in the python language proper or perhaps > in the implementation of external-C functions also to enable/assert solidity? > Also, while I think I follow you, perhaps you could explain this some more? The purpose of solidification is to solve (sidestep, really) a difficult problem: How do you get type information about globals? They're subject to change at any instant, after all. One approach would be to assume that they won't be assigned some invalid value (a value which does not match the typing information), but this is not a robust solution (after all, I *can* execute 'sys.maxint = "the spanish inquisition"' even if I shouldn't.). Another would be to perform a type assertion whenever the value is loaded, but that is likely to have a substantial runtime penalty greater than any possible benefit of optional static typing. So I chose a third method, which is to provide a way to talk about items which should be considered "constant" and thus have the loads hoisted into constant loads at "compile" time, something like import math; math.__solid__ = dir(math) import sys; sys.__solid__ = (sys.maxint, ...) __solid__ = ['math', 'sys', ...] __builtin__.__solid__ = ['range', ...] def f(x): return range(6) x = solidify(x) So, anyhow, I hope you understand that the goal is not merely removing LOAD_GLOBAL or LOAD_ATTR calls, but to make efficient, safe type checking possible. Jeff
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4