Efficient Wrappers for Instance Methods

Sven R. Kunze srkunze at mail.de
Wed Feb 3 15:32:01 EST 2016


Hi,

as you might have noticed, I am working on 
https://github.com/srkunze/xheap right now.

In order to make it even faster and closer to heapq's baseline 
performance, I wonder if there is a possibility of creating fast 
wrappers for functions.


Please compare

https://github.com/srkunze/xheap/blob/ca56ac55269ce0bc7b61d28ba9ceb41e9075476a/xheap.py#L29
https://github.com/srkunze/xheap/blob/ca56ac55269ce0bc7b61d28ba9ceb41e9075476a/xheap.py#L32

with

https://github.com/srkunze/xheap/blob/ca56ac55269ce0bc7b61d28ba9ceb41e9075476a/xheap.py#L44


Why is it not possible to create a method from a function like I aliased 
replace with poppush?

If I am not completely mistaken, it saves 1 stack frame, right?


Best,
Sven



More information about the Python-list mailing list