Re: Efficient Wrappers for Instance Methods

2016-02-04 Thread Sven R. Kunze
On 04.02.2016 19:35, Random832 wrote: On Thu, Feb 4, 2016, at 11:18, Sven R. Kunze wrote: On 04.02.2016 00:47, Random832 wrote: On Wed, Feb 3, 2016, at 16:43, Sven R. Kunze wrote: Actually a nice idea if there were no overhead of creating methods for all heap instances separately. I'll keep th

Re: Efficient Wrappers for Instance Methods

2016-02-04 Thread Random832
On Thu, Feb 4, 2016, at 11:18, Sven R. Kunze wrote: > On 04.02.2016 00:47, Random832 wrote: > > On Wed, Feb 3, 2016, at 16:43, Sven R. Kunze wrote: > >> Actually a nice idea if there were no overhead of creating methods for > >> all heap instances separately. I'll keep that in mind. :) > > What abo

Re: Efficient Wrappers for Instance Methods

2016-02-04 Thread Sven R. Kunze
On 04.02.2016 00:47, Random832 wrote: On Wed, Feb 3, 2016, at 16:43, Sven R. Kunze wrote: Actually a nice idea if there were no overhead of creating methods for all heap instances separately. I'll keep that in mind. :) What about changing the class of the object to one which is inherited from i

Re: Efficient Wrappers for Instance Methods

2016-02-03 Thread Random832
On Wed, Feb 3, 2016, at 16:43, Sven R. Kunze wrote: > Actually a nice idea if there were no overhead of creating methods for > all heap instances separately. I'll keep that in mind. :) What about changing the class of the object to one which is inherited from its original class and has the method

Re: Efficient Wrappers for Instance Methods

2016-02-03 Thread Sven R. Kunze
On 03.02.2016 22:34, Bernardo Sulzbach wrote: Did Peter's suggestion work? Somewhat for a single Heap class. However, it breaks inheritance. -- https://mail.python.org/mailman/listinfo/python-list

Re: Efficient Wrappers for Instance Methods

2016-02-03 Thread Sven R. Kunze
On 03.02.2016 22:15, Peter Otten wrote: The technical reason is that functions written in C don't implement the descriptor protocol. The bound method is created by invoking the __get__ method of the class attribute: Good to know. :-/ It's sad. These functions just look so method-like. Bes

Re: Efficient Wrappers for Instance Methods

2016-02-03 Thread Sven R. Kunze
On 03.02.2016 22:19, Peter Otten wrote: You could try putting self.heappush = functools.partial(heapq.heappush, self) into the initializer. Actually a nice idea if there were no overhead of creating methods for all heap instances separately. I'll keep that in mind. :) -- https://mail.pytho

Re: Efficient Wrappers for Instance Methods

2016-02-03 Thread Bernardo Sulzbach
Did Peter's suggestion work? -- https://mail.python.org/mailman/listinfo/python-list

Re: Efficient Wrappers for Instance Methods

2016-02-03 Thread Sven R. Kunze
On 03.02.2016 22:14, Bernardo Sulzbach wrote: Thanks for quoting, for some reason my client always replies to the person and not the list (on this list only). I did what I could. I could show you a lambda function there, but it doesn't solve anything. If there is a way to avoid a wrapper, I don'

Re: Efficient Wrappers for Instance Methods

2016-02-03 Thread Peter Otten
Sven R. Kunze wrote: > On 03.02.2016 22:06, Bernardo Sulzbach wrote: >> I may say something wrong, but this is what I see going on: >> >> When you get "replace = heapreplace" you are creating a data attribute >> called replace (you will access it by self.replace or >> variable.replace) that is an

Re: Efficient Wrappers for Instance Methods

2016-02-03 Thread Bernardo Sulzbach
Thanks for quoting, for some reason my client always replies to the person and not the list (on this list only). I did what I could. I could show you a lambda function there, but it doesn't solve anything. If there is a way to avoid a wrapper, I don't know. -- https://mail.python.org/mailman/list

Re: Efficient Wrappers for Instance Methods

2016-02-03 Thread Peter Otten
Sven R. Kunze wrote: > 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 c

Re: Efficient Wrappers for Instance Methods

2016-02-03 Thread Sven R. Kunze
On 03.02.2016 22:06, Bernardo Sulzbach wrote: I may say something wrong, but this is what I see going on: When you get "replace = heapreplace" you are creating a data attribute called replace (you will access it by self.replace or variable.replace) that is an alias for heapreplace. When you cal

Re: Efficient Wrappers for Instance Methods

2016-02-03 Thread Sven R. Kunze
On 03.02.2016 21:40, Bernardo Sulzbach wrote: I am not entirely sure about what your question is. Are you talking about the "heapreplace expected 2 arguments, got 1" you get if you set replace = heapreplace? Yes, I think so. I might ask differently: why do I need to write wrapper method when

Re: Efficient Wrappers for Instance Methods

2016-02-03 Thread Bernardo Sulzbach
I am not entirely sure about what your question is. Are you talking about the "heapreplace expected 2 arguments, got 1" you get if you set replace = heapreplace? -- https://mail.python.org/mailman/listinfo/python-list