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.4.tar.gz (4.6 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.4-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for s3_ls-0.0.4.tar.gz
Algorithm Hash digest
SHA256 cc5b330f405c438962137c30360805721301a4d65ae68ae03893e88fdbba49ed
MD5 c2e49d756a551066eb4f1a74cbd0c0af
BLAKE2b-256 71bd8680afb669c7376b3a91af4d5a247990b07ba7741371dc10ef5603b5eedd

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for s3_ls-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 73da6f46b64a11a6da5256b59748347c3ad8c53a2f4154dab79ba728a99ff6ff
MD5 6975a7c9449e60426509dd1232f3f01e
BLAKE2b-256 80f76e2725faf4d41146f1dbc5aebd6e41d72fed451210eaa36a95530486327e

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