{"id":5724,"library":"smmap2","title":"smmap2 - Shared Memory Map","description":"smmap2 is a mirror package on PyPI for the `smmap` library, specifically distributing version 3.0.1 of `smmap` under the name `smmap2`. It provides an efficient way to memory-map data, particularly for large files, and is primarily intended as an internal dependency for specific versions of `GitPython` or projects requiring this exact older version. The upstream `smmap` project (at `gitpython-developers/smmap`) has since progressed to version 5.x.x.","status":"active","version":"3.0.1","language":"python","source_language":"en","source_url":"https://github.com/gitpython-developers/smmap2","tags":["memory-mapping","gitpython","low-level","mirror-package"],"install":[{"cmd":"pip install smmap2","lang":"bash","label":"Install smmap2"}],"dependencies":[],"imports":[{"note":"Despite the package being named `smmap2` on PyPI, the Python import path for its modules is `smmap`.","wrong":"from smmap2 import SlidingWindowMap","symbol":"SlidingWindowMap","correct":"from smmap import SlidingWindowMap"}],"quickstart":{"code":"import os\nimport mmap\nimport tempfile\nfrom smmap import SlidingWindowMap\n\n# Create a dummy file for memory mapping\ndata_to_map = b\"This is some test data that will be memory-mapped.\" * 10 # make it a bit larger\nfile_size = len(data_to_map)\n\n# Use tempfile to create a temporary file\nwith tempfile.NamedTemporaryFile(delete=False) as tmp_file:\n    tmp_file.write(data_to_map)\n    tmp_file_path = tmp_file.name\n\ntry:\n    # Open the file for reading\n    with open(tmp_file_path, \"rb\") as f:\n        # Create an mmap object for the file\n        m = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ)\n\n        # Create a SlidingWindowMap instance\n        # For this example, we'll map the entire file into a single window\n        window_size = file_size\n        s = SlidingWindowMap(m, begin=0, size=file_size, window_size=window_size)\n\n        # Access data through the sliding window map\n        read_data = s[0:file_size]\n        print(f\"Read data length: {len(read_data)}\")\n        print(f\"First 50 bytes: {read_data[:50].decode()}\")\n\n        assert read_data == data_to_map\n        print(\"Data successfully read and verified.\")\n\n        s.close()\n        m.close()\n\nfinally:\n    # Clean up the temporary file\n    if os.path.exists(tmp_file_path):\n        os.remove(tmp_file_path)\n","lang":"python","description":"Demonstrates how to initialize and use `SlidingWindowMap` to read data from a memory-mapped file. It creates a temporary file, maps it into memory, and then accesses the data via `SlidingWindowMap`."},"warnings":[{"fix":"Always use `from smmap import ...` for importing modules and classes from the `smmap2` package.","message":"The PyPI package is named `smmap2`, but the Python import statement uses `from smmap import ...`. Attempting `from smmap2 import ...` will result in an `ImportError`.","severity":"gotcha","affected_versions":"3.0.1"},{"fix":"If you need the latest `smmap` functionality or broad Python compatibility, install `smmap` directly via `pip install smmap`. Be aware of potential API differences between v3.x and v5.x.","message":"The `smmap2` package (v3.0.1) is an older, specific version of the `smmap` library. It does not track the latest developments of the upstream `smmap` project (which is currently at v5.x.x at `gitpython-developers/smmap`). Users expecting the latest `smmap` features or fixes will be disappointed.","severity":"gotcha","affected_versions":"3.0.1"},{"fix":"For new projects or modern Python environments, prefer `pip install smmap`. If you must use `smmap2`, thoroughly test its compatibility with your specific Python version.","message":"The `smmap2` package (v3.0.1) specifies very old Python compatibility requirements (`>=2.6, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*`). While it might still run on modern Python versions (3.6+), it is not actively tested or guaranteed to be fully compatible. For modern Python applications, the newer `smmap` v5.x.x is recommended.","severity":"deprecated","affected_versions":"3.0.1"},{"fix":"Consider if you truly need this low-level memory mapping functionality directly, or if a higher-level library that depends on `smmap` (like `GitPython`) would be more appropriate for your use case.","message":"This package is primarily intended as an internal dependency for specific versions of `GitPython` and similar projects. It is not typically designed for direct, standalone application development, and its API documentation might be sparse or outdated.","severity":"gotcha","affected_versions":"3.0.1"},{"fix":"If migrating from `smmap2` to `smmap` (v5.x.x), review the `smmap` changelog and update your code to reflect the new API and usage patterns.","message":"The `smmap` library underwent significant changes between versions 3.x (as mirrored by `smmap2`) and 5.x. Code written for `smmap` v3.0.1 will likely not be directly compatible with `smmap` v5.x.x without modification due to API changes.","severity":"breaking","affected_versions":"3.0.1"}],"env_vars":null,"search_vec":"'/smmap':68 '3.0.1':19 '5':74 'data':35 'depend':47 'develop':67 'distribut':17 'effici':29 'exact':57 'file':39 'gitpython':52,66,79 'gitpython-develop':65 'intend':43 'intern':46 'larg':38 'level':82 'librari':15 'low':81 'low-level':80 'map':4,34,78 'memori':3,33,77 'memory-map':32,76 'mirror':8,84 'mirror-packag':83 'name':24 'older':58 'packag':9,85 'particular':36 'primarili':42 'progress':71 'project':54,63 'provid':27 'pypi':11 'requir':55 'share':2 'sinc':70 'smmap':14,21,62 'smmap2':1,5,25 'specif':16,49 'upstream':61 'version':18,50,59,73 'way':30 'x.x':75","created_at":"2026-04-14T03:41:00.945256+00:00","updated_at":"2026-04-16T21:51:49.909797+00:00","problems":{"verify_error":"Traceback (most recent call last):\n  File \"<string>\", line 1, in <module>\nImportError: cannot import name 'SlidingWindowMap' from 'smmap' (/tmp/tmpgr6uryml/venv/lib/python3.12/site-packages/smmap/__init__.py). Did you mean: 'SlidingWindowMapBuffer'?"},"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"3.0.1","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/gitpython-developers/smmap","docs":null,"changelog":null,"pypi":"https://pypi.org/project/smmap2/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["data"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-30","next_check":"2026-08-01","install_tag":null}}