# Optimizations

Automatic optimizations for your code.

Source: https://docs.eugo.io/docs/optimizations/

---

# Automatic Optimizations

Eugo automatically optimizes your code for performance without any changes required on your part.

When you run Python code in EugoIDE, Eugo analyzes your operations and applies optimizations based on the workload. You write standard Python. Eugo handles the rest.

## GPU Offloading

Eugo automatically moves computationally intensive operations to GPUs when available.

Operations like matrix multiplication, deep learning training, and other parallelizable tasks run on GPU hardware without code changes. You import NumPy or PyTorch and write your code normally. Eugo determines which operations benefit from GPU execution and handles the offloading.

## Vectorization

Eugo vectorizes your code to use SIMD instructions on modern CPUs.

This optimization converts scalar operations into vector operations that process multiple data points simultaneously. Element-wise arithmetic on large arrays sees significant speedups from automatic vectorization.

You don't annotate your code or use special functions. Eugo applies vectorization during execution.

## Parallelization

Eugo distributes your code across multiple CPU cores using Ray for automatic parallelization.

Tasks that can split into independent subtasks — like map-reduce operations, batch processing, or parallel data transformations — run across available cores automatically. This can speed up execution by orders of magnitude.

You write sequential Python code. Eugo identifies parallelization opportunities and distributes the work.

## JIT Compilation

Eugo uses Just-In-Time (JIT) compilation to convert Python code into optimized machine code at runtime.

When Python 3.13+ becomes the default runtime, Eugo will apply the [Python 3.13 JIT compiler](https://peps.python.org/pep-0744/) for additional performance. This works similarly to Numba but distributes compiled code across the cluster.

Tight loops and numerical computations see the largest speedups from JIT compilation. The compilation happens automatically on first execution, then the optimized code runs on all subsequent calls.

## Best Practices

While Eugo optimizes automatically, you can write code that takes better advantage of these optimizations:

- **Use NumPy arrays** instead of Python lists for numerical operations
- **Avoid unnecessary loops** — vectorized operations optimize better than explicit loops
- **Batch operations** when possible instead of processing items one at a time
- **Use standard library functions** — built-in operations have optimized paths

You don't need to change working code. These practices simply help Eugo apply optimizations more effectively.
