aoc2018 | Rust solutions to the Advent Of Code | Learning library
kandi X-RAY | aoc2018 Summary
kandi X-RAY | aoc2018 Summary
Rust solutions to the Advent Of Code 2018
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of aoc2018
aoc2018 Key Features
aoc2018 Examples and Code Snippets
Community Discussions
Trending Discussions on aoc2018
QUESTION
Can anyone explain why the below code gets a stack overflow? I had hoped that Saxon would identify the template as tail recursive, and optimise it, allowing for a very large number of iterations - in reality it gets a stack overflow after ~1000 iterations. I'm executing as per below:
...ANSWER
Answered 2019-Oct-15 at 09:53Confirmed that this works (with tail recursion) under 9.9, with or without bytecode generation enabled, but under 9.8 it succeeds only if bytecode generation is switched off. I think the difference between the releases is that 9.9 is smarter at deciding not to use bytecode generation in cases where it would interfere with tail recursion.
To see why it fails when using function calls rather than templates I would need to see the code. The two cases use different mechanisms internally. In particular functions are by default evaluated in "pull" mode (they return an iterator over the result), templates in "push" mode (they write results out to a result tree). The most noticeable difference is that returning a sequence containing the result of a recursive call (for example select="$x, f:myself($x - 1)
) can be done tail-recursively with templates, but not with functions. But that doesn't seem to apply to your case. Also, for templates we handle mutual recursion of two or more templates, while with functions we only handle self-recursion.
The following version appears to work using tail-recursion using either 9.8 or 9.9, with or without bytecode generation. (Under 9.8, though, there is an oddity which I haven't had time to investigate: after producing the output value, the process doesn't actually exit.)
QUESTION
log.getLogger
again in the main file. This caused 2 instances of the logger to be made. The solution is to remove the second call, OR rename one of the two.
I am attempting to setup a custom logger for my current project, and I am having difficulty with getting it to work properly outside of __init__.py
file. The issue is that anything I log is logged twice.
My Code:
__Init__.py:
...ANSWER
Answered 2018-Dec-02 at 01:16As jobevers aluded to in his comment, you are attaching two stream handlers to the 'Main' logger. First in the __init__.py
and again in __main__.py
. This also explains why your logging from within __init__.py
is working correctly as __main__.py
hasn't attached the second handler yet.
I suspect the reason you did not expect this behaviour is because you were expecting the loggers to be distinct. But the loggers you defined in __init__.py
and in variables.py
are actually the same. When you retrieve a logger using logging.getLogger(logger_name)
with the same logger_name it returns the same logger. So when you call logging.getLogger('Main')
in variables.py
it still has the StreamHandler on it from when it was added in __init__.py
.
Depending on what behaviour you want you should either give them distinct names or remove the second addHandler.
It should be noted that logger names follow a hierarchy. Log configuration for my_package
will also configure logging for anything my_package.model
, my_package.views
, etc... The root logger is simply the logger with the empty string (logging.getLogger("")
).
For more details I'd recommend just going through the official docs.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install aoc2018
Rust is installed and managed by the rustup tool. Rust has a 6-week rapid release process and supports a great number of platforms, so there are many builds of Rust available at any time. Please refer rust-lang.org for more information.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page