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
Fixed python depth limit; Introduce mixins. #60
Conversation
m2cgen/interpreters/interpreter.py
Outdated
return re.sub("(?!^)([A-Z]+)", r"_\1", name).lower() | ||
|
||
|
||
class BaseAstToCodeInterpreter(BaseAstInterpreter): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we even need this intermediate entity?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise mixins have attribute _cg
which they are not aware of what it is.
m2cgen/interpreters/mixins.py
Outdated
from m2cgen.interpreters.interpreter import BaseAstToCodeInterpreter | ||
|
||
|
||
class BinExpressionDepthTrackingMixin(BaseAstToCodeInterpreter): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some reason I thought that mixins supposed to be outside of any particular class hierarchy. This is why they are "mixed in". In our case they are still inheriting the very base class. I'm not sure that it's that important, it just doesn't feel right :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise mixins have attribute _cg
which they are not aware of what it is and IDE don't resolve methods of this attribute.
18bae56
to
2566351
Compare
2566351
to
23c856b
Compare
m2cgen/interpreters/interpreter.py
Outdated
return re.sub("(?!^)([A-Z]+)", r"_\1", name).lower() | ||
|
||
|
||
class BaseAstToCodeInterpreter(BaseInterpreter): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was Ast
remained here on purpose? Or did you just miss this one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
m2cgen/interpreters/mixins.py
Outdated
|
||
class BinExpressionDepthTrackingMixin(BaseAstToCodeInterpreter): | ||
""" | ||
This mixin provides an ability to call a custom cook when depth of the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cook
-> hook
? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
m2cgen/interpreters/mixins.py
Outdated
|
||
It also provides flag `with_linear_algebra` which indicates whether | ||
linear algebra was used during interpretation. It can be used to add | ||
dependencies. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add corresponding third party dependencies that provide linear algebra operations and/or data structures
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thanks!
No description provided.