Skip to main content

PyHamCTY

PyPI Package Coverage Python versions

Author: Andreas Schawo, DF1ASC (HamQTH, eQSL)

This package provides reading country databases (CTY files) and searching callsign related information.

Also, it provides downloading of the most recent version. Per default, it acts with CTY files but BigCTY can also be loaded.

Until October 2026 this library was part of DragonLog, but I decided to place it as a separate project and did some enhancements.

Since May 2026 I also ported the cty module to Rust in hamcty. This speeds up even more thus I'm looking forward to generate Python bindings for it.

Remarks

The longitude in the result (lon field in Country) is as commonly used from 0° to 180° to the East and from 0° to -180° to the West.

Usage

After installing the package you can simply do

import pyhamcty

cty = pyhamcty.CountryData()  # Loads integrated CTY DB
res = cty.country('DA2CDE')
print(res.code, res.continent, res.cq, res.itu)

If you want to load a more recent CTY do

import pyhamcty

pyhamcty.load_current('cty.csv')
cty = pyhamcty.CountryData('cty.csv')

If faster loading time is critical you can dump a CountryData to pickle file and restore it from there

import os
import pyhamcty

if os.path.isfile('cty.pckl'):
    cty = pyhamcty.load_pickle('cty.pckl')
else:
    cty = pyhamcty.CountryData('cty.csv')
    pyhamcty.dump_pickle(cty, 'cty.pckl')

You also can run it from console to do a simple search. Without callsign it produces the version entity.

pysearch_cty DA2CDE

or to download the most recent CTY file and use it (-c for CTY, -b for BigCTY)

pysearch_cty -c cty.csv
pysearch_cty DA2CDE cty.csv

Performance

I recently stumbled upon ctyparser and notctyparser as I examined Not1MM. So I was curious how both will compare. I measured the memory footprint, loading time and searching with 20 callsigns 100 times.

The data for the bench is the same version VER20260603 (3DA, Kingdom of Eswatini). I tested the correct country resolution with "LU1DD", "LU1ZB", "LU1ZA", "LU1ZAW".

Remark: ctyparser and notctyparser both do not provide a complete callsign resolution, so I took the function from Not1MM

The first value is for CTY, the second for BigCTY.

Lib pyhamcty (.csv) pyhamcty (.pckl) [not]ctyparser (.dat) [not]ctyparser (.json)
Size 102.3 / 293.7 kB 624.4 kB / 2 MB 99.8 / 339.9 kB 1.1 / 4.8 MB
Memory 149.4 / 474.8 kB 153.8 / 481.9 kB 202.8 / 938.8 kB same as .dat
Load 39.132 / 117.4 ms 14.239 / 44.081 ms 63.72 / 267.932 ms 20.296 / 92.563 ms
Search 311.125 / 501.82 ms same as .csv 5.041 / 24.489 s same as .dat
Per call 0.16 / 0.25 ms same as .csv 2.52 / 12.2 ms same as .dat

© 2026 by Andreas Schawo is licensed under CC BY-SA 4.0

except the included CTY database files (see corresponding copyright) and some code in bench_notctyparser.py (see code comments).

Metadata

Release files for PyHamCTY 1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for PyHamCTY 1.0
File Size Uploaded
pyhamcty-1.0.tar.gz 55.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for PyHamCTY 1.0
File Interpreter ABI Platform
pyhamcty-1.0-py3-none-any.whl Python 3 none any Details

Total release size: 109.8 kB

Release files / pyhamcty-1.0.tar.gz

Download URL pyhamcty-1.0.tar.gz
Size 55.8 kB
Tags Source
SHA-256 checksum
How to use checksums
4fa9191d385784223a6e6184573add378352932b128466a62d3f143caf797154
BLAKE2b-256 checksum
How to use checksums
0ddff43f7fb1f4ee573ebb3093980fb4af3990eac1f38725d6e05c2d1ea74b03
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.21 {"installer":{"name":"uv","version":"0.12.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Linux Mint","version":"22.3","id":"zena","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / pyhamcty-1.0-py3-none-any.whl

Download URL pyhamcty-1.0-py3-none-any.whl
Size 54.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b8a0f9dd16fd7750b541bb6da69db17d0792fd07a4447d5ea155c7034fe7ea4f
BLAKE2b-256 checksum
How to use checksums
aee6f6eeeebaeb9411f06ab5d4ebfdb43f9950650df270adda87bfe58f865102
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.21 {"installer":{"name":"uv","version":"0.12.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Linux Mint","version":"22.3","id":"zena","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

1.0.1

2 release files

This release

1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page