Skip to content

Conversation

@rnixx
Copy link
Member

@rnixx rnixx commented Nov 4, 2025

No description provided.

rnixx and others added 30 commits October 21, 2025 13:32
- Convert setup.py/setup.cfg to pyproject.toml
- Implement PEP 420 implicit namespaces (remove namespace declarations)
- Delete namespace-only __init__.py files
- Add /build to .gitignore

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
- Remove obsolete MANIFEST.in file (now using hatchling)
- Update Python classifiers to 3.10-3.14
- Update GitHub Actions workflows to test Python 3.10-3.14
- Remove PyPy from workflows

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Implement a high-performance Cython version of odict using C structs
with native pointers instead of Python lists for the double-linked list.

Features:
- C struct-based nodes with PyObject* pointers for prev_key, value, next_key
- Proper memory management with Py_INCREF/Py_DECREF
- All 70+ methods from pyodict implemented
- Pickle serialization support via __reduce__
- 100% API compatibility with Python odict

Files added:
- src/odict/codict.pyx: Cython implementation (~760 lines)
- tests/test_codict.py: Complete test suite mirroring test_odict.py
- setup.py: Cython build configuration
- include.mk: Custom Makefile targets for building codict
- plans/codict-implementation.md: Detailed implementation documentation
- CLAUDE.md: Project documentation for Claude Code

Files modified:
- pyproject.toml: Added cython>=3.0 build dependency
- Makefile: Added BUILD_CODICT setting
- src/odict/bench.py: Extended with codict benchmarks and comparisons

Import: from odict.codict import codict
Build: make codict or make install
Add __eq__ and __ne__ methods to _codict class to properly compare
codicts by their items rather than object identity. This fixes the
test_delete and test_pickle test failures.

All 71 tests now pass (36 codict + 35 odict).
- Fix time.clock() deprecation (use time.perf_counter())
- Add comprehensive pickle serialization tests (test_pickle_codict.py)
- Add detailed performance analysis documentation

Results:
- codict is 15-38% faster than Python odict for creation
- codict is ~36% more memory efficient per node
- All pickle protocols (0-5) fully supported
- 8 comprehensive pickle tests, all passing

Performance highlights (1M objects):
- Creation: codict 759ms vs odict 897ms (15% faster)
- Memory: ~32MB savings for 1M nodes
- Full API compatibility maintained
Document complete codict project:
- All objectives achieved and exceeded
- 71/71 tests passing
- 15-38% performance improvement
- 36% memory reduction
- 100% API compatibility
- Full pickle support
- Production ready

Status: ✅ Complete
Created comprehensive analysis investigating whether additional performance
gains are possible using Cython's cpdef function declarations.

Finding: cpdef optimization is NOT feasible with current architecture due
to fundamental Cython limitation. The _codict class must remain a regular
Python class to support multiple inheritance with dict, but only cdef
classes can have cpdef methods.

Added files:
- CPDEF_ANALYSIS.md: Comprehensive technical analysis with alternatives
- benchmark_cpdef.py: Micro-benchmark tool for optimization candidate analysis

Updated:
- IMPLEMENTATION_SUMMARY.md: Added cpdef investigation section and findings

Conclusion: Current implementation represents optimal achievable performance
(15-38% faster, 36% less memory) while maintaining 100% API compatibility.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Completely refactored bench.py to provide detailed performance and memory
comparisons for ALL 50+ public API methods across dict, OrderedDict, odict,
and codict implementations.

New Features:
- BenchmarkRunner class for systematic benchmarking
- One table per method showing all implementations
- Time and memory measurements with percentage vs odict baseline
- 50+ test functions covering all public API methods:
  * 17 basic dictionary operations
  * 11 iteration operations
  * 22 ordered dict specific operations
- Organized into 3 categories for clarity
- Summary statistics at the end
- Smart method availability detection (N/A for unavailable methods)
- Memory tracking using tracemalloc (per-operation delta)
- Warmup iterations to avoid cold start effects
- Configurable sizes (1K, 10K, 100K, 1M) and iteration counts

Output Format:
- Clean, readable tables with proper alignment
- Negative % means faster/less memory than odict (baseline)
- Descriptions for each method
- Size breakdown for each test

Added Files:
- BENCH_USAGE.md: Comprehensive usage guide with examples

Changes:
- src/odict/bench.py: Complete refactor (846 lines, was 163 lines)
  * Previous simple create/delete benchmarks replaced with comprehensive suite
  * Maintains backward compatibility (can still run with python -m odict.bench)

Usage:
  python3 -m odict.bench  # Run full suite (~10-30 minutes)

  # Or customize:
  from odict.bench import BenchmarkRunner, SIZES
  SIZES = [1000, 10000]  # Faster testing with smaller sizes

Benefits:
- Identify exactly which methods benefit from codict optimization
- Fair comparison using odict as baseline
- Memory-aware benchmarking
- Production-ready output format
- Easy to extend with custom benchmarks

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Restructured 4 large documentation files into 13 semantically organized
files in docs/source/ for future Sphinx documentation generation.

New Structure:
  docs/source/
  ├── user-guide/         (4 files - getting started, usage)
  │   ├── overview.md
  │   ├── installation.md
  │   ├── usage.md
  │   └── api-reference.md
  ├── technical/          (4 files - implementation details)
  │   ├── architecture.md
  │   ├── performance.md
  │   ├── memory.md
  │   └── benchmarking.md
  └── development/        (5 files - contributor documentation)
      ├── development.md
      ├── testing.md
      ├── building.md
      ├── optimizations.md
      └── future-work.md

Changes:
- Deleted: BENCH_USAGE.md, CPDEF_ANALYSIS.md, IMPLEMENTATION_SUMMARY.md,
  PERFORMANCE_ANALYSIS.md (large mixed-purpose files)
- Created: 13 focused, semantically organized files
- Kept: CLAUDE.md (project documentation for Claude Code)

Benefits:
- Semantic organization by purpose (user/technical/development)
- Easier navigation with smaller, focused files
- Sphinx-ready structure
- Better discoverability with descriptive filenames
- Reduced duplication (cpdef content appears once)
- Maintainability (easier to update specific sections)

All filenames use lowercase with hyphen separation (kebab-case) as
specified for Sphinx compatibility.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
rnixx and others added 3 commits November 4, 2025 12:09
Major changes:
- Removed src/odict/codict.pyx (Cython implementation)
- Removed include.mk (codict build targets)
- Updated pyproject.toml: removed Cython build dependencies
- Simplified src/odict/__init__.py: direct import of pure Python odict
- Updated tests: removed codict parametrization
- Updated benchmarks: removed codict references and examples
- Updated documentation: README.md and CLAUDE.md

All 128 tests pass with pure Python implementation only.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Changes:
- Deleted docs/source/user-guide/overview.md (entirely about codict)
- Batch replaced `codict` with `odict` in all documentation
- Removed "Cython-optimized", "Cython", "or codict" patterns from docs
- Updated 12 documentation files in docs/source/

Note: Coverage is at 99% (1 line in abstract base class not covered).
The missing line (odict.py:54) is NotImplementedError in _base_odict._dict_cls()
which was previously covered by codict but is now unreachable.

All 128 tests pass. Benchmarks run successfully.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@rnixx rnixx marked this pull request as draft November 4, 2025 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants