|
289 | 289 | </label> |
290 | 290 | <ul class="md-nav__list" data-md-component="toc" data-md-scrollfix> |
291 | 291 |
|
292 | | - <li class="md-nav__item"> |
293 | | - <a href="#why-pythonembed" class="md-nav__link"> |
294 | | - <span class="md-ellipsis"> |
295 | | - |
296 | | - Why PythonEmbed? |
297 | | - |
298 | | - </span> |
299 | | - </a> |
300 | | - |
301 | | -</li> |
302 | | - |
303 | 292 | <li class="md-nav__item"> |
304 | 293 | <a href="#quick-look" class="md-nav__link"> |
305 | 294 | <span class="md-ellipsis"> |
|
1319 | 1308 | </label> |
1320 | 1309 | <ul class="md-nav__list" data-md-component="toc" data-md-scrollfix> |
1321 | 1310 |
|
1322 | | - <li class="md-nav__item"> |
1323 | | - <a href="#why-pythonembed" class="md-nav__link"> |
1324 | | - <span class="md-ellipsis"> |
1325 | | - |
1326 | | - Why PythonEmbed? |
1327 | | - |
1328 | | - </span> |
1329 | | - </a> |
1330 | | - |
1331 | | -</li> |
1332 | | - |
1333 | 1311 | <li class="md-nav__item"> |
1334 | 1312 | <a href="#quick-look" class="md-nav__link"> |
1335 | 1313 | <span class="md-ellipsis"> |
|
1375 | 1353 | <h1 id="pythonembed">PythonEmbed</h1> |
1376 | 1354 | <p>Run Python code from Java — with full CPython compatibility and zero setup.</p> |
1377 | 1355 | <p>PythonEmbed embeds a real CPython interpreter in your JVM application via a subprocess + <a href="https://msgpack.org/">MessagePack</a> binary protocol — just pure Java and CPython. All C extensions (numpy, scipy, torch) work out of the box.</p> |
1378 | | -<h2 id="why-pythonembed">Why PythonEmbed?</h2> |
1379 | | -<table> |
1380 | | -<thead> |
1381 | | -<tr> |
1382 | | -<th>Concern</th> |
1383 | | -<th>PythonEmbed</th> |
1384 | | -<th>Jython/GraalPy</th> |
1385 | | -</tr> |
1386 | | -</thead> |
1387 | | -<tbody> |
1388 | | -<tr> |
1389 | | -<td>CPython compatibility</td> |
1390 | | -<td>Full — numpy, scipy, torch, all C extensions</td> |
1391 | | -<td>Limited to pure Python</td> |
1392 | | -</tr> |
1393 | | -<tr> |
1394 | | -<td>Crash isolation</td> |
1395 | | -<td>Python segfaults never kill the JVM</td> |
1396 | | -<td>Native crash kills the JVM</td> |
1397 | | -</tr> |
1398 | | -<tr> |
1399 | | -<td>Setup</td> |
1400 | | -<td>One Gradle plugin line</td> |
1401 | | -<td>Manual venv or JVM flag configuration</td> |
1402 | | -</tr> |
1403 | | -<tr> |
1404 | | -<td>Performance</td> |
1405 | | -<td>MessagePack binary protocol, 2–5× faster than JSON</td> |
1406 | | -<td>In-process (JNI-based)</td> |
1407 | | -</tr> |
1408 | | -</tbody> |
1409 | | -</table> |
1410 | 1356 | <h2 id="quick-look">Quick Look</h2> |
1411 | 1357 | <p>Add the Gradle plugin:</p> |
1412 | 1358 | <div class="highlight"><pre><span></span><code><a id="__codelineno-0-1" name="__codelineno-0-1" href="#__codelineno-0-1"></a><span class="n">plugins</span><span class="w"> </span><span class="o">{</span> |
|
0 commit comments