-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add method to get functional representation of engine #9
Comments
👍 This is a great idea. Definitely agree with the |
Could we do it with a simple implementation like this, or do we want something that would support parallel execution? |
I think that might work, I think we would need a test similar to the pseudocode outlined above. You're basically currying the function |
Ah yeah you're right - any modifications to that instance of the class would be reflected by the function. I'll read up on functools and work on currying the function with a copy of all the instance variables. Good catch. |
This idea works as-is under the assumption that at no point during the execution of the To answer this
It will, since it is still bound to that engine object, even though we no longer have to explicitly reference it when we call the If we can't guarantee this, we should be able to accomplish what we want by implementing |
Assigned to @geezhawk |
Currently, the engines are all statefull classes. This is useful for many things, but the final use case is an operation that looks much like a pure function:
func(url) = source
It is possible to add a method into the base engine class that will return a purely functional equivalent of the
get_page_source
method such that if you do (in pseudocode):Further, the functions returned,
a
andb
here, would take just one argument,url
, and have all of the state of the parent object baked in. This allows us to do some interesting things more performantly, like:source_generator = (a(url) for url in urls)
or
The text was updated successfully, but these errors were encountered: