<p>I've likely got this wrong, but using <code>mprf</code> objects provides access to base R <code>intersect</code>, <code>union</code>, <code>setdiff</code>, while a <code>sort(...</code> needs to be wrapped inside a <code>mprf(sort(...), 'bits')</code>:</p>
<pre><code>library(Rmprf)

f3 &lt;- mpfr(5:9, 53)
f4 &lt;- mpfr(8:12, 53)

intersect(f3,f4)
2 'mpfr' numbers of precision  53   bits 
[1] 8 9

setdiff(f3,f4)
3 'mpfr' numbers of precision  53   bits 
[1] 5 6 7

f3 %in% f4
[1] FALSE FALSE FALSE  TRUE  TRUE

# large integers from vignette
ns &lt;- mpfr(1:24, 120)
fact_ns &lt;- factorial(ns)
fact_ns[20:24]
5 'mpfr' numbers of precision  120   bits 
[1]      2432902008176640000     51090942171709440000   1124000727777607680000
[4]  25852016738884976640000 620448401733239439360000

pasc80 &lt;- chooseMpfr.all(n = 80, 77)[40:49]
pasc80
10 'mpfr' numbers of precision  77   bits 
 [1] 107507208733336176461620 104885081691059684352800  97393290141698278327600
 [4]  86068488962431036661600  72375774809317008101800  57900619847453606481440
 [7]  44054819449149483192400  31869443856831541032800  21910242651571684460050
[10]  14308729894903957198400

mpfr(sort(union(fact_ns[20:24], pasc80)), 77)
15 'mpfr' numbers of precision  77   bits 
 [1]      2432902008176640000     51090942171709440000   1124000727777607680000
 [4]  14308729894903957198400  21910242651571684460050  25852016738884976640000
 [7]  31869443856831541032800  44054819449149483192400  57900619847453606481440
[10]  72375774809317008101800  86068488962431036661600  97393290141698278327600
[13] 104885081691059684352800 107507208733336176461620 6204484017332394393600
</code></pre>
<p>so for these operations <code>sets</code> is not necessary, and assuming your workflow is amenable to <code>Rmprf</code> based objects.</p>
<p>As the problem is presented in the context of 'precision', one likely wouldn't want a function that promotes or demotes sets to their highest/lowest 'prec', but be intentionally involved in the decision (though, admittedly, I looked for one).</p>
<p>Here, renaming your f3 &amp; f4 below to f7 &amp; f8:</p>
<pre><code>getPrec(f7)[1]
[1] 10
getPrec(f8)[1]
[1] 20
intersect(roundMpfr(f7, 20), f8)
2 'mpfr' numbers of precision  20   bits 
[1] 9 6
intersect(f7, roundMpfr(f8, 10))
2 'mpfr' numbers of precision  10   bits 
[1] 9 6
</code></pre>
<p>So it appears that 'precision handling' is required as to set operations, though such additional cycles may be avoided if it is plausible that upon mpfr creation, defaults would render the inputs the same precision. Using OEIS as inputs:</p>
<pre><code>library(OEIS.R) # git clone of EnriquePH/OEIS.R --no-build-vignettes
A011784 &lt;- OEIS_bfile('A011784')
max(nchar(A011784$data$A011784))
[1] 221
max(nchar(A078140$data$A078140))
[1] 228

# so we see precision handling here, perhaps
A011784_228 &lt;- mpfr(A011784$data$A011784, 228)
A078140_228 &lt;- mpfr(A078140$data$A078140, 228)

intersect(A011784_228,A078140_228)
2 'mpfr' numbers of precision  228   bits 
[1] 1 3
</code></pre>
<p>Ah, so little in common. And it is probably not that your sequences are in OEIS, rather checking for similarity to those from your sequences 'from the wild', and this doesn't reflect your workflow.</p>
<p>As to using lists:</p>
<pre><code>is(A011784_bigz)
[1] &quot;bigz&quot;     &quot;oldClass&quot; &quot;Mnumber&quot;  &quot;mNumber&quot; 
&gt; is(A011784_228)
[1] &quot;mpfr&quot;    &quot;list&quot;    &quot;Mnumber&quot; &quot;mNumber&quot; &quot;vector&quot;
</code></pre>
<p>So those as.list cycles have already been expended in mpfr creation.</p>
<p>And some related, light reading <a href="https://arxiv.org/abs/2202.02384" rel="nofollow noreferrer">primitive sets</a> from recent news.</p>
Efficient code to do set operations with bigz-class values?
<p>The current release of the package <code>gmp</code> does not support set operations such as <code>intersect</code>, <code>setdiff</code> , etc.  I'm doing some work with number sequences  (see <a href="http://oeis.org/" rel="nofollow noreferrer">OEIS</a> for examples) and need to handle large collections of  large integers.  I'm currently stuck with using various loops to generate the desired differences or intersections; while I could probably generate compiled (Rccp, etc) code, I'm hoping to find a way within existing <code>R</code> functions and packages.</p>