Hi all,
I have two questions about a class, which we'll call MyWrapperClass,
in a package to which I'm contributing.
1) MyWrapperClass wraps functions. Each instance has an attribute
called 'value' and a method called 'eval', which calls the wrapped
function. An instance D that depends on instances A, B and C can be
created as follows:
@mywrapperclass
def D(A, B, C):
return foo(A.value, B.value, C.value)
Now that D exists, the call D.eval() will work without any arguments
(D remembers that the arguments are A, B and C and passes their values
to foo). What is the standard terminology for such classes, and does
anyone know of a package that implements them in a nice way? (It's
easy enough to roll our own, but reading about other implementations
might give us good ideas).
2) D.eval() will frequently be called multiple times in succession
before A.value, B.value or C.value has had the chance to change. It
would be _extremely_ helpful to have D detect this situation and skip
recomputation. I'm looking for the fastest safe way to do this.
There's no restriction on what kind of object A.value, etc. are, so
unfortunately they might be mutable.
Our current solution is to have D compare A.value, B.value and C.value
to an internal cache using the 'is' operator (and put a big warning in
the docs about not changing 'value' attributes in-place). Not exactly
safe, but the speed savings over comparison with '==' will be
significant. Is this OK, bad or an abomination?
Again it would be helpful to know the terminology associated with the
behavior I'm looking for and any packages that implement it nicely.
Many thanks in advance and apologies for the long post,
Anand 2 986
On Nov 12, 1:05 am, "Anand Patil" <anand.prabhakar.pa...@gmail.com>
wrote:
Hi all,
I have two questions about a class, which we'll call MyWrapperClass,
in a package to which I'm contributing.
1) MyWrapperClass wraps functions. Each instance has an attribute
called 'value' and a method called 'eval', which calls the wrapped
function. An instance D that depends on instances A, B and C can be
created as follows:
@mywrapperclass
def D(A, B, C):
return foo(A.value, B.value, C.value)
Now that D exists, the call D.eval() will work without any arguments
(D remembers that the arguments are A, B and C and passes their values
to foo). What is the standard terminology for such classes, and does
anyone know of a package that implements them in a nice way? (It's
easy enough to roll our own, but reading about other implementations
might give us good ideas).
2) D.eval() will frequently be called multiple times in succession
before A.value, B.value or C.value has had the chance to change. It
would be _extremely_ helpful to have D detect this situation and skip
recomputation. I'm looking for the fastest safe way to do this.
There's no restriction on what kind of object A.value, etc. are, so
unfortunately they might be mutable.
Our current solution is to have D compare A.value, B.value and C.value
to an internal cache using the 'is' operator (and put a big warning in
the docs about not changing 'value' attributes in-place). Not exactly
safe, but the speed savings over comparison with '==' will be
significant. Is this OK, bad or an abomination?
Again it would be helpful to know the terminology associated with the
behavior I'm looking for and any packages that implement it nicely.
Many thanks in advance and apologies for the long post,
Anand
Cells (A dataflow extension to CLOS) seems like what you want: http://common-lisp.net/project/cells/
I think there was talk of a Python version a while back...
-- bjorn
thebjorn a écrit :
On Nov 12, 1:05 am, "Anand Patil" <anand.prabhakar.pa...@gmail.com>
wrote:
>Hi all,
I have two questions about a class, which we'll call MyWrapperClass, in a package to which I'm contributing.
1) MyWrapperClass wraps functions. Each instance has an attribute called 'value' and a method called 'eval', which calls the wrapped function. An instance D that depends on instances A, B and C can be created as follows:
@mywrapperclass def D(A, B, C): return foo(A.value, B.value, C.value)
Now that D exists, the call D.eval() will work without any arguments (D remembers that the arguments are A, B and C and passes their values to foo). What is the standard terminology for such classes, and does anyone know of a package that implements them in a nice way? (It's easy enough to roll our own, but reading about other implementations might give us good ideas).
2) D.eval() will frequently be called multiple times in succession before A.value, B.value or C.value has had the chance to change. It would be _extremely_ helpful to have D detect this situation and skip recomputation. I'm looking for the fastest safe way to do this. There's no restriction on what kind of object A.value, etc. are, so unfortunately they might be mutable.
Our current solution is to have D compare A.value, B.value and C.value to an internal cache using the 'is' operator (and put a big warning in the docs about not changing 'value' attributes in-place). Not exactly safe, but the speed savings over comparison with '==' will be significant. Is this OK, bad or an abomination?
Again it would be helpful to know the terminology associated with the behavior I'm looking for and any packages that implement it nicely.
Many thanks in advance and apologies for the long post, Anand
Cells (A dataflow extension to CLOS) seems like what you want:
http://common-lisp.net/project/cells/
I think there was talk of a Python version a while back...
-- bjorn
pycells : http://pycells.pdxcb.net/
but also trellis : http://peak.telecommunity.com/DevCenter/Trellis This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Mark E. Fenner |
last post by:
In the code below, the class DifferentCache utilizes three different
memoization (caching) strategies. Neither the function Memoize1 or
the class Memoize2 will be adequate for all three of these...
|
by: Alex Wolff |
last post by:
Hello,
How do I keep IIS from caching/remembering username/password?
Here is the situation:
I have created an asp script which sits on server1. The script makes an
http call to server2...
|
by: Lawrence San |
last post by:
I'm trying to test some simple JavaScript meant to speed up the display
of my Web pages for readers using modems, but I have a fast DSL
connection and I'm having trouble visualizing how effective...
|
by: techievasant |
last post by:
hello everyone,
Iam vasant from India..
I have a test+interview on C /C++ in the coming month so plz help me
by giving some resources of FAQS, interview questions, tracky
questions, multiple...
|
by: Shark |
last post by:
Hi everyone, check this out: http://tinyurl.com/rw8b4
|
by: Jobs |
last post by:
What is application object ?
Application object can used in situation where we want data to be
shared across users globally.
What's the difference between Cache object and application object...
|
by: Jobs |
last post by:
All answers to the below interview questions are at
http://www.geocities.com/dotnetinterviews/
or
you can download the complete answer zip file from...
|
by: mesut |
last post by:
Hi colleagues,
I have a small issue. I don't know how to solve it. I'm caching a
property value : True or False. I do this manually and it works. But I
would like to remove the cache if the the...
|
by: aarklon |
last post by:
Hi all,
I was reading the book "C interview Questions" By J. Rajaram
published in india by firewall media, after going through the book
i have the following doubts
1) why the following...
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: giovanniandrean |
last post by:
The energy model is structured as follows and uses excel sheets to give input data:
1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
|
by: NeoPa |
last post by:
Hello everyone.
I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report).
I know it can be done by selecting :...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
|
by: Teri B |
last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course.
0ne-to-many. One course many roles.
Then I created a report based on the Course form and...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM)
Please note that the UK and Europe revert to winter time on...
|
by: nia12 |
last post by:
Hi there,
I am very new to Access so apologies if any of this is obvious/not clear.
I am creating a data collection tool for health care employees to complete. It consists of a number of...
|
by: isladogs |
last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, Mike...
| |