A spaced repetition Python library.
Project description
SpacedRepPy
A spaced repetition Python library implementing SM-2, Leitner, and FSRS-6 algorithms.
Installation
Use uv or pip to install spacedreppy.
uv add spacedreppy
# or
pip install spacedreppy
Usage
SM-2
from datetime import datetime, timezone
from spacedreppy import SM2Scheduler
scheduler = SM2Scheduler()
# Each call returns the next due timestamp and interval.
due_timestamp, interval = scheduler.compute_next_due_interval(
attempted_at=datetime.now(timezone.utc), result=4
)
The result parameter is a quality score from the SM-2 algorithm:
| Score | Meaning |
|---|---|
| 0 | Complete blackout — no recall at all |
| 1 | Incorrect response, but the correct answer seemed easy to recall once seen |
| 2 | Incorrect response, but the correct answer was remembered upon seeing it |
| 3 | Correct response with serious difficulty |
| 4 | Correct response after some hesitation |
| 5 | Perfect response with no hesitation |
Scores of 3 or higher count as correct and advance the repetition schedule. Scores below 3 reset the interval.
Leitner System
from datetime import datetime, timezone
from spacedreppy import LeitnerScheduler
scheduler = LeitnerScheduler()
# result=1 for correct, result=0 for incorrect
due_timestamp, interval = scheduler.compute_next_due_interval(
attempted_at=datetime.now(timezone.utc), result=1
)
The result parameter is a binary score:
| Score | Meaning |
|---|---|
| 0 | Incorrect |
| 1 | Correct |
Correct answers promote the card to the next box; incorrect answers send it back to the first box. The default box intervals (in days) are [1, 3, 7, 14, 30], but you can provide your own:
scheduler = LeitnerScheduler(intervals=[2, 5, 10])
FSRS-6
from datetime import datetime, timezone
from spacedreppy import FSRSScheduler
scheduler = FSRSScheduler()
# result: 1=Again, 2=Hard, 3=Good, 4=Easy
due_timestamp, interval = scheduler.compute_next_due_interval(
attempted_at=datetime.now(timezone.utc), result=3
)
The result parameter is a rating from the FSRS algorithm:
| Rating | Meaning |
|---|---|
| 1 (Again) | Forgot the card |
| 2 (Hard) | Remembered with serious difficulty |
| 3 (Good) | Remembered after some hesitation |
| 4 (Easy) | Remembered easily |
FSRS-6 models memory with Stability (S) and Difficulty (D), using a power-law forgetting curve with 21 trainable parameters. You can customize the scheduler:
scheduler = FSRSScheduler(
request_retention=0.85, # target retention (default: 0.9)
maximum_interval=365, # max interval in days (default: 36500)
)
Custom model weights (e.g., from the FSRS optimizer) can also be provided:
scheduler = FSRSScheduler(weights=my_optimized_weights)
Development
This project uses uv for dependency management and just as a command runner.
# Install dependencies
just install
# Run tests
just test
# Run formatters
just codestyle
# Run all linting (tests + style + mypy + safety)
just lint
License
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file spacedreppy-0.5.0.tar.gz.
File metadata
- Download URL: spacedreppy-0.5.0.tar.gz
- Upload date:
- Size: 71.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9cead9e799c7f75652c991c0ff09a4b1adb253158368a2ac7513e3adeda4d504
|
|
| MD5 |
a1bbacf571a581eb7fe8f1cb28901e94
|
|
| BLAKE2b-256 |
8398fabe9b2fc172cf3b1207d7bc33d78bc8f592aa92e3dd554ed0b8eb80300f
|
Provenance
The following attestation bundles were made for spacedreppy-0.5.0.tar.gz:
Publisher:
publish.yml on lschlessinger1/spacedreppy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spacedreppy-0.5.0.tar.gz -
Subject digest:
9cead9e799c7f75652c991c0ff09a4b1adb253158368a2ac7513e3adeda4d504 - Sigstore transparency entry: 1238354157
- Sigstore integration time:
-
Permalink:
lschlessinger1/spacedreppy@f6242405c89a96711fb7070d9a19aad7177279ed -
Branch / Tag:
refs/tags/v0.5.0 - Owner: https://github.com/lschlessinger1
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f6242405c89a96711fb7070d9a19aad7177279ed -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file spacedreppy-0.5.0-py3-none-any.whl.
File metadata
- Download URL: spacedreppy-0.5.0-py3-none-any.whl
- Upload date:
- Size: 10.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c8106b69c4c0eb81499dcd81b4e05f181e07c3e2172227028752ed45d905589c
|
|
| MD5 |
a80d116a8d4bfb06927773c5beca250e
|
|
| BLAKE2b-256 |
d25e9ec7753d94cacc0fc2daf633a5a81acf34f6b0924bdbbe9e4986eb425cb5
|
Provenance
The following attestation bundles were made for spacedreppy-0.5.0-py3-none-any.whl:
Publisher:
publish.yml on lschlessinger1/spacedreppy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spacedreppy-0.5.0-py3-none-any.whl -
Subject digest:
c8106b69c4c0eb81499dcd81b4e05f181e07c3e2172227028752ed45d905589c - Sigstore transparency entry: 1238354163
- Sigstore integration time:
-
Permalink:
lschlessinger1/spacedreppy@f6242405c89a96711fb7070d9a19aad7177279ed -
Branch / Tag:
refs/tags/v0.5.0 - Owner: https://github.com/lschlessinger1
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f6242405c89a96711fb7070d9a19aad7177279ed -
Trigger Event:
workflow_dispatch
-
Statement type: