#14304: New implementation of unramified p-adics using FLINT and templates
-------------------------------------+-------------------------------------
Reporter: roed | Owner: roed
Type: enhancement | Status: needs_review
Priority: major | Milestone: sage-6.1
Component: padics | Resolution:
Keywords: | Merged in:
Authors: Julian Rueth, | Reviewers: David Roe, Julian
David Roe | Rueth
Report Upstream: N/A | Work issues:
Branch: | Commit:
u/roed/ticket/14304 | c647f4a1413547a47196f77acade2d7c45b46c28
Dependencies: #12555, #12173 | Stopgaps:
-------------------------------------+-------------------------------------
Comment (by jdemeyer):
Replying to [comment:28 roed]:
> So, does anyone have suggestions on how to rewrite the ugly nested try
blocks in `PowComputer_flint_unram.__cinit__`? Julian and I couldn't
think of a better way to do it that would never have a memory leak or a
double free.
I had a look at the code and the current code actually is never going to
work. The C-level functions like `fmpz_poly_init` and `mpz_init` never
raise exceptions. So, the `try`/`except` is pointless. As far as I can
tell, there are two kinds of exceptions which can happen: a `MemoryError`
in MPIR or a `KeyboardInterrupt`. In both cases, the exception will be
raised by `sig_on()` and none of the `finally` blocks are executed.
If you want to be absolutely correct, every single allocation should be
wrapped individually in `sig_on()`/`sig_off()`. Example for 2 allocations:
{{{
sig_on()
alloc1()
sig_off()
try:
sig_on()
alloc2()
sig_off()
except BaseException:
free1()
raise
}}}
But actually, this is allocating extremely little memory (surely less than
1000 bytes), so why not simply
{{{
alloc1()
alloc2()
}}}
--
Ticket URL: <http://trac.sagemath.org/ticket/14304#comment:30>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/groups/opt_out.