Skip to main content

Fast S3 object listing

Project description

s3-ls

Fast S3 object listing

Introduction

Listing S3 directory containing millions of objects is very painful because it has to be sequential, but maximum number of objects per one request is limited to 1000.

# First 1k objects
response = s3.list_objects_v2(
    Bucket=bucket, Prefix=prefix, StartAfter=""
)
last_key = response["Contents"][-1]["Key"]

# Next 1k objects
response = s3.list_objects_v2(
    Bucket=bucket, Prefix=prefix, StartAfter=last_key
)
...

s3-ls parallelizes it by partitioning the prefix into multiple parts and listing them in parallel.

prefix = "path/to/dir/"

prefix_1 = "path/to/dir/a"
prefix_2 = "path/to/dir/b"
prefix_3 = "path/to/dir/c"
... (70 prefixes)

In this way, the listing process can be done 70x faster in the ideal case.

Quick Start

Installation

pip install s3-ls

Usage

s3-ls s3://bucket/prefix
from s3_ls import list_objects

for obj in list_objects(bucket, prefix, **s3_kwargs):
    key = obj["Key"]

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

s3_ls-0.0.2.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

s3_ls-0.0.2-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file s3_ls-0.0.2.tar.gz.

File metadata

  • Download URL: s3_ls-0.0.2.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.6

File hashes

Hashes for s3_ls-0.0.2.tar.gz
Algorithm Hash digest
SHA256 9e25572e16dc961f5ea977bc0808a0addca590c11ebc00f6b477d48ec75e2a77
MD5 301fbed0242c22e5e4558d92c2eabfdc
BLAKE2b-256 eb5f6b5d4fec21672abc52fc770e44f367cd598f4371dd60eb17321a7ada139a

See more details on using hashes here.

File details

Details for the file s3_ls-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: s3_ls-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.6

File hashes

Hashes for s3_ls-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3371f7881ff7c4efc4773ac828b6d0f9ce3f048f495dd68f80e5cd92f1d2d79f
MD5 8f9ba8ba328d4ce4b5321b9bc675e30a
BLAKE2b-256 1fc9d584aa4bdc7ce54cfcdc3d7c29124e767b3fbc93f10b5df30a537b6e1fa6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page