Skip to content

Commit cb59b61

Browse files
committed
Add LICENSE and README.md
1 parent b6c9030 commit cb59b61

File tree

2 files changed

+150
-0
lines changed

2 files changed

+150
-0
lines changed

LICENSE

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Copyright 2025 Grant Jenks
2+
3+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4+
this file except in compliance with the License. You may obtain a copy of the
5+
License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software distributed
10+
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
11+
CONDITIONS OF ANY KIND, either express or implied. See the License for the
12+
specific language governing permissions and limitations under the License.

README.md

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
# ArrayDeque
2+
3+
ArrayDeque is a fast, array-backed deque implementation for Python written in
4+
C. It aims to provide high-performance double-ended queue operations similar to
5+
Python’s built-in collections.deque with a straightforward, efficient design.
6+
7+
8+
## Features
9+
10+
- Fast appends and pops at both ends.
11+
- Efficient random access and in-place item assignment.
12+
- Full support for iteration, slicing (via __getitem__ and __setitem__),
13+
and common deque methods.
14+
- A comprehensive CPython C-extension for optimal performance.
15+
- Includes a detailed benchmark comparing performance with collections.deque.
16+
17+
18+
## Installation
19+
20+
There are two ways to install ArrayDeque.
21+
22+
23+
### Installation via pip
24+
25+
There are pre-built wheels available on PyPI, install it directly:
26+
27+
pip install arraydeque
28+
29+
30+
### Building from source
31+
32+
Clone the repository and run:
33+
34+
git clone https://github.com/yourusername/arraydeque.git
35+
cd arraydeque
36+
pip install -e .
37+
38+
This will compile the C-extension and install the module into your Python
39+
environment.
40+
41+
42+
## Usage
43+
44+
After installation, you can use ArrayDeque just like a regular Python deque:
45+
46+
from arraydeque import ArrayDeque
47+
48+
# Create an ArrayDeque instance
49+
dq = ArrayDeque()
50+
51+
# Append items on the right
52+
dq.append(10)
53+
dq.append(20)
54+
55+
# Append items on the left
56+
dq.appendleft(5)
57+
58+
# Access by index
59+
print(dq[0]) # -> 5
60+
61+
# Pop elements
62+
print(dq.pop()) # -> 20
63+
print(dq.popleft()) # -> 5
64+
65+
ArrayDeque supports the standard deque API including extend, extendleft (which
66+
reverses the order), clear, and iteration.
67+
68+
69+
## Benchmarking
70+
71+
A benchmark script ([benchmark.py](benchmark.py)) is provided to compare the
72+
performance of ArrayDeque against Python's built-in collections.deque. The
73+
benchmark runs tests for operations such as append, appendleft, pop, popleft,
74+
random access, and a mixed workload. Each operation is run several times and
75+
the median is reported to give an accurate performance comparison.
76+
77+
After running the benchmark (see instructions below), a plot (saved as
78+
`plot.png`) is generated that visually compares the two implementations using a
79+
fivethirtyeight style bar chart.
80+
81+
To run the benchmark:
82+
83+
python benchmark.py
84+
85+
Inspect `plot.png` for a detailed performance comparison.
86+
87+
88+
## Testing
89+
90+
Tests are implemented using the standard `unittest` framework. The test suite
91+
verifies all core functionalities of the ArrayDeque module and ensures that
92+
edge cases such as underflow are handled properly.
93+
94+
To run the tests:
95+
96+
python test_arraydeque.py
97+
98+
Alternatively, if you’re using [tox](https://tox.readthedocs.io/), just run:
99+
100+
tox
101+
102+
The project’s CI workflows (GitHub Actions) automatically build and test
103+
ArrayDeque on Ubuntu, macOS, and Windows.
104+
105+
106+
## Continuous Integration
107+
108+
This project uses GitHub Actions to automate testing, linting, and release management.
109+
110+
- [Release Workflow](.github/workflows/release.yml): Builds wheels for Ubuntu, macOS, and Windows, then publishes to PyPI.
111+
- [Test Workflow](.github/workflows/test.yml): Runs tests on multiple Python versions.
112+
- [tox.ini](tox.ini): Configures testing environments and lint/format tasks using [ruff](https://beta.ruff.rs/).
113+
114+
115+
## Development
116+
117+
To set up your development environment:
118+
119+
1. Clone the repository.
120+
2. Create a virtual environment:
121+
122+
python -m venv env
123+
source env/bin/activate # On Unix/macOS
124+
env\Scripts\activate # On Windows
125+
126+
3. Install the development dependencies:
127+
128+
pip install tox
129+
130+
4. To format and lint the code, run:
131+
132+
tox -e format
133+
tox -e lint
134+
135+
136+
## License
137+
138+
This project is distributed under the Apache2 License.

0 commit comments

Comments
 (0)