Favorite non-python language trick?
Ron Adam
rrr at ronadam.com
Fri Jun 24 17:17:09 EDT 2005
George Sakkis wrote:
> "Joseph Garvin" wrote:
>
>
>>I'm curious -- what is everyone's favorite trick from a non-python
>>language? And -- why isn't it in Python?
>
>
> Although it's an optimization rather than language trick, I like the
> inline functions/methods in C++. There has been a thread on that in the
> past (http://tinyurl.com/8ljv5) and most consider it as useless and/or
> very hard to implement in python without major changes in the language
> (mainly because it would introduce 'compile-time' lookup of callables
> instead of runtime, as it is now). Still it might be useful to have for
> time-critical situations, assuming that other optimization solutions
> (psyco, pyrex, weave) are not applicable.
>
> George
Thanks for the link George, It was interesting.
I think some sort of inline or deferred local statement would be useful
also. It would serve as a limited lambda (after it's removed), eval
alternative, and as a inlined function in some situations as well I think.
Something like:
name = defer <expression>
then used as:
result = name()
The expression name() will never have arguments as it's meant to
reference it's variables as locals and probably will be replaced
directly with names's byte code contents at compile time.
Defer could be shortened to def I suppose, but I think defer would be
clearer. Anyway, it's only a wish list item for now.
Regards,
Ron
More information about the Python-list
mailing list