Code Explainers

Code explainers tagged #memory-efficiency

php
<?php
 
namespace App\Services\Reports;
 

Streaming a monthly revenue CSV in Laravel

csv-export lazy-collections eloquent-query
Intermediate 8 steps
php
<?php
 
namespace App\Actions\Imports;
 

Streaming CSV imports with Laravel batches

lazy-collections job-batching streaming
Advanced 9 steps
python
from contextlib import contextmanager
from typing import Iterator
 
import psycopg2

Streaming Postgres rows with a server-side cursor

generators context-managers database-streaming
Intermediate 7 steps
python
import csv
 
from django.http import StreamingHttpResponse
from django.utils.timezone import now

Streaming a CSV export in Django

streaming csv-export generators
Intermediate 7 steps
python
import ijson
from decimal import Decimal
 
 

Streaming JSON aggregation with ijson

streaming json-parsing generators
Intermediate 7 steps
ruby
class InactiveAccountCleanup
  BATCH_SIZE = 500
  INACTIVITY_THRESHOLD = 18.months
 

Batch-processing dormant users in Rails

batch-processing activerecord service-object
Intermediate 9 steps
php
<?php
 
namespace App\Http\Controllers;
 

Streaming a large CSV export in Laravel

streaming csv-export memory-efficiency
Intermediate 9 steps
python
import csv
import io
from datetime import datetime
 

Streaming a CSV export in Flask

streaming generators csv
Intermediate 9 steps
python
import csv
import io
from datetime import date
 

Streaming a CSV export in FastAPI

streaming async-generators csv
Advanced 8 steps
go
func (h *TransactionHandler) ExportCSV(c *gin.Context) {
	ctx := c.Request.Context()
	filters := parseTransactionFilters(c)
 

Streaming a CSV export in Gin

streaming csv-export database-cursor
Intermediate 8 steps
php
<?php
 
declare(strict_types=1);
 

Streaming file lines with a PHP generator

generators lazy-evaluation file-io
Intermediate 7 steps