Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-codegen
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Christian Heinigk
dune-codegen
Commits
ae7af941
Commit
ae7af941
authored
8 years ago
by
Dominic Kempf
Browse files
Options
Downloads
Patches
Plain Diff
Implement a generic context manager that globally defines some value
parent
3b85a515
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
python/dune/perftool/generation/__init__.py
+3
-1
3 additions, 1 deletion
python/dune/perftool/generation/__init__.py
python/dune/perftool/generation/context.py
+24
-0
24 additions, 0 deletions
python/dune/perftool/generation/context.py
with
27 additions
and
1 deletion
python/dune/perftool/generation/__init__.py
+
3
−
1
View file @
ae7af941
...
...
@@ -25,4 +25,6 @@ from dune.perftool.generation.loopy import (domain,
)
from
dune.perftool.generation.context
import
(
cache_context
,
)
\ No newline at end of file
generic_context
,
get_generic_context_value
,
)
This diff is collapsed.
Click to expand it.
python/dune/perftool/generation/context.py
+
24
−
0
View file @
ae7af941
...
...
@@ -29,3 +29,27 @@ def get_context_tags():
for
items
in
_cache_context_stack
:
result
=
result
+
items
return
result
_generic_context_cache
=
{}
class
_GenericContext
(
object
):
def
__init__
(
self
,
key
,
value
):
self
.
key
=
key
self
.
value
=
value
assert
key
not
in
_generic_context_cache
def
__enter__
(
self
):
_generic_context_cache
[
self
.
key
]
=
self
.
value
def
__exit__
(
self
,
exc_type
,
exc_value
,
traceback
):
del
_generic_context_cache
[
self
.
key
]
def
generic_context
(
key
,
value
):
return
_GenericContext
(
key
,
value
)
def
get_generic_context_value
(
key
):
return
_generic_context_cache
[
key
]
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment