Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
28fe14f
Add pop function with an index argument to single-linked list, with t…
kata198 Apr 1, 2017
4c1b144
Add pop with index arg to double-linked list
kata198 Apr 1, 2017
8181feb
Fix warnings on sllist
kata198 Apr 1, 2017
7c5f375
Fix warnings in dllist
kata198 Apr 1, 2017
8f7b965
Add copyright note
kata198 Apr 1, 2017
1acfe14
Make help strings the same for pop function
kata198 Apr 1, 2017
c8e7184
Clear last_access_node if we need to in idx-pop, and use dllistnode_d…
kata198 Apr 1, 2017
9195502
Add some more tests, test each pop in the full-pop-out, and pop from …
kata198 Apr 2, 2017
fc7cf01
Greatly simplify indexed pop. Check first if we are popping left or r…
kata198 Apr 2, 2017
fc16922
Add 'middle' to double-linked list
kata198 Apr 2, 2017
45a6121
We are already relinking at the bottom, so get rid of these.
kata198 Apr 2, 2017
ee71daf
Merge branch 'master' into 0.5branch
kata198 Apr 2, 2017
7898e64
Remove the last_accessed node and index from dllist. It is broken som…
kata198 Apr 2, 2017
7cf6f18
Move out magic number for when middle index begins into a define
kata198 Apr 2, 2017
4aae917
Add benchmark script
kata198 Apr 2, 2017
7ab2e91
Add benchmark script
kata198 Apr 2, 2017
f3ed019
Remove some noise form llist_test
kata198 Apr 3, 2017
e308f6f
Add more test for node_at
kata198 Apr 3, 2017
020e197
double-linked list: Use middle on node-access, when available.
kata198 Apr 3, 2017
4ef4284
Use consistant generic adjustment method, instead of the maybe-somewh…
kata198 Apr 3, 2017
3e2a674
Add executable bit to files, and change setup.py to using env python
kata198 Apr 3, 2017
eb71b31
Skip a compare and jump straight, and other micro optimizations in pop
kata198 Apr 3, 2017
8315705
Add inline function to check and conditionally clear middle
kata198 Apr 3, 2017
8970d59
Use check instead of do inline function here
kata198 Apr 3, 2017
97260aa
Remove errant return
kata198 Apr 3, 2017
7ecdddb
Merge branch '0.5branch_middle' into 0.5branch
kata198 Apr 3, 2017
3cf5660
Remove dlist hash function which DOES NOT WORK, generates duplicate h…
kata198 Apr 3, 2017
6018dd8
Garbage collect before and after every iteration, to take non-work gc…
kata198 Apr 5, 2017
fec5fac
Garbage collect before and after every iteration, to take non-work gc…
kata198 Apr 5, 2017
018d06a
Merge branch '0.5branch' - Replaces last_accessed with "middle" for much
kata198 Apr 5, 2017
36c44a2
Mark sllist as unhashable. This method is not safe, and conflicts all…
kata198 Apr 5, 2017
c379a1d
Mark sllist as unhashable. This method is not safe, and conflicts all…
kata198 Apr 5, 2017
ca90eaf
Just comment out the hash functions
kata198 Apr 5, 2017
d6eead2
Just comment out the hash functions
kata198 Apr 5, 2017
d41a5a8
Add index and rindex methods to both dllist and sllist
kata198 Apr 5, 2017
bee71e8
Fix braces warning
kata198 Apr 5, 2017
08b6e03
Comment out debug function
kata198 Apr 5, 2017
578a4ee
Merge branch '0.5branch'
kata198 Apr 5, 2017
99c9b86
Add test for 'contains'
kata198 Apr 5, 2017
c2a67b6
Bump version to 0.5.0 and update CHANGES
kata198 Apr 5, 2017
b00c14e
Merge branch '0.5branch'
kata198 Apr 5, 2017
e24d257
Move types into header files. Converts types to extern in header, and
kata198 Apr 7, 2017
d82f362
Improve extend and extendleft, higher performance all-around, and als…
kata198 Apr 7, 2017
f9f4310
Add benchmark_extend
kata198 Apr 7, 2017
05aa302
Update ChangeLog
kata198 Apr 7, 2017
0c84350
Merge branch '0.5branch'
kata198 Apr 7, 2017
8011204
Dlist implementation of slicing / subscript
kata198 Apr 9, 2017
058d829
Slist implementation of slicing / subscript
kata198 Apr 10, 2017
ab85a81
Move some common stuff to llist.h and llist_types.h
kata198 Apr 10, 2017
c99fad1
Add tilda files to gitignore
kata198 Apr 10, 2017
324bb60
Update Changes
kata198 Apr 10, 2017
febdbf7
Some minor cleanups
kata198 Apr 10, 2017
4acb06a
Update speed_test - Fix for python3, and fix popleft... was actually …
kata198 Apr 10, 2017
d95db50
speed_text: fix columns to always line up and make speed_test executable
kata198 Apr 10, 2017
2702fa9
Implement contains method
kata198 Apr 10, 2017
6f00302
Add two more benchmarks
kata198 Apr 10, 2017
3d3d416
Fix warning
kata198 Apr 10, 2017
bba344a
Greatly improve performance with extending on dllist
kata198 Apr 10, 2017
9ea5e9e
Greatly improve performance of extending on sllist
kata198 Apr 10, 2017
4d452b8
Simplify extending by pulling out the first set (removes the conditio…
kata198 Apr 10, 2017
593f2cd
Rename this fork to cllist, bump to version 1.0.0 to prepare for release
kata198 Apr 12, 2017
f4faf4e
Add __version__ and __version_tuple__
kata198 Apr 12, 2017
6ff909e
Fix warnings and fix normalize_indexes for python2
kata198 Apr 12, 2017
3f45f02
Rename READMEs to match markdown (for github) and rst (for pypi). Als…
kata198 Apr 12, 2017
22d953c
Add pydocs
kata198 Apr 12, 2017
0b6b649
Fixup setup.py
kata198 Apr 12, 2017
1156292
Add my name as an author
kata198 Apr 12, 2017
1fe6810
Update READMEs
kata198 Apr 12, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ dist
*.pyc
*.so
*.swp
*~
30 changes: 30 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
* cllist-1.0

Forked from python-llist to python-cllist

Work by Tim Savannah:

- Implement pop(idx) to pop any given index
- Implement "contains" sequence method, so the "in" operator doesn't run the whole list multiple times
- Implement "index" and "rindex" methods to return an index/rindex
- Remove "last_accessed_idx" and "last_accessed" node from dllist, replace with "middle" which is used when
the list size exceeds a certain value (defined as 10). This greatly improves random-access and random-pop performance
on dllist to be comprable or better to that of a base python list
- Remove the "hash" function, which did NOT generate unique hashes (very easy to construct two linked lists with same hash,
such as [1, 5, 7] and [5, 1, 7] or [2, 1] and [3]
- Remove all compiler warnings
- Add some basic benchmarks
- Add some more tests
- Some minor cleanups

- Move types into headers, make generic LList node and list structures, which are common to both double and single linked lists.
- Allow a double-linked list to extend with a single-linked list, and a single-linked list to extend with a double (for much higher performance)

- Implement mappings on sllist and dllist
- Implement slicing (including with step) on both sllist and dllist

- Add __version__ and __version_tuple__

- Some general optimizations


* llist-0.4 (2013-01-01)

- Python 3.x support
Expand Down
8 changes: 7 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
include Makefile CHANGES LICENSE MANIFEST MANIFEST.in
include Makefile
include CHANGES
include LICENSE
include MANIFEST.in
include README.rst
include README.md
recursive-include src *.c *.h
recursive-include docs *.py *.rst
recursive-include pydocs *.html
include docs/Makefile docs/make.bat
graft docs/_static
graft docs/_templates
Expand Down
36 changes: 0 additions & 36 deletions README

This file was deleted.

55 changes: 55 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
cllist - C-implemented Linked Lists for Python
==============================================

cllist is an extension module for CPython providing basic linked list
data structures.

Collections implemented in the llist module perform well in problems
which rely on fast insertions, pops, and removal of elements in
the middle of a sequence.

For this kind of workload, they can be significantly faster than
collections.deque or standard Python lists.


This project was forked from https://github.com/ajakubek/python-llist

and adds many features and enhancements to the original, under a new name "cllist".

The cllist version now lives at https://github.com/kata198/python-cllist

If you were using the previous module, you can change to this new module, it is completely backwards (but not forwards) compatible.



Single Linked List
------------------

Singly linked lists are provided by the "sllist" module. This is your basic single-linked list, and might be useful for some scenarios.

A single linked list is far less efficient at everything than the double-linked list implementation.


Double Linked List
------------------

A double-linked list is provided by the "dllist" module.

This provides great performance when doing pops and insertions at random (in the middle), or at either end.

This implementation has been enhanced by implementing a "middle" marker.

This "middle" marker is used when the list size exceeds 10 elements, and is used in all operations which involve walking the list,

which ensures that AT MOST N/4 elements will need to be walked (so the shortest distance from either start, middle, or end is calculated, and walked from there).

This additional feature makes this linked list much more efficient on larger data sets than a standard double-linked list implementation.


Why use a linked list?
----------------------

A linked list should be used when you are going to be adding or removing elements in the middle of the dataset. A standard python list forces the entire list
to be reallocated and copied when such happens, whereas this can do so without reallocating.


55 changes: 55 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
cllist - C-implemented Linked Lists for Python
==============================================

cllist is an extension module for CPython providing basic linked list
data structures.

Collections implemented in the llist module perform well in problems
which rely on fast insertions, pops, and removal of elements in
the middle of a sequence.

For this kind of workload, they can be significantly faster than
collections.deque or standard Python lists.


This project was forked from https://github.com/ajakubek/python-llist

and adds many features and enhancements to the original, under a new name "cllist".

The cllist version now lives at https://github.com/kata198/python-cllist

If you were using the previous module, you can change to this new module, it is completely backwards (but not forwards) compatible.



Single Linked List
------------------

Singly linked lists are provided by the "sllist" module. This is your basic single-linked list, and might be useful for some scenarios.

A single linked list is far less efficient at everything than the double-linked list implementation.


Double Linked List
------------------

A double-linked list is provided by the "dllist" module.

This provides great performance when doing pops and insertions at random (in the middle), or at either end.

This implementation has been enhanced by implementing a "middle" marker.

This "middle" marker is used when the list size exceeds 10 elements, and is used in all operations which involve walking the list,

which ensures that AT MOST N/4 elements will need to be walked (so the shortest distance from either start, middle, or end is calculated, and walked from there).

This additional feature makes this linked list much more efficient on larger data sets than a standard double-linked list implementation.


Why use a linked list?
----------------------

A linked list should be used when you are going to be adding or removing elements in the middle of the dataset. A standard python list forces the entire list
to be reallocated and copied when such happens, whereas this can do so without reallocating.


1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
.. module:: llist
:synopsis: Linked list datatypes for Python

.. moduleauthor:: Timothy Savannah <kata198@gmail.com>
.. moduleauthor:: Adam Jakubek <ajakubek@gmail.com>
.. moduleauthor:: Rafał Gałczyński <rafal.galczynski@gmail.com>

Expand Down
109 changes: 109 additions & 0 deletions pydocs/cllist.dllist.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: class dllist</title>
<meta charset="utf-8">
</head><body bgcolor="#f0f0f8">
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#000000" face="helvetica, arial"><strong>cllist.dllist</strong> = <a name="cllist.dllist">class dllist</a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr>

<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
<td colspan=2><tt>Doubly&nbsp;linked&nbsp;list<br>&nbsp;</tt></td></tr>
<tr><td>&nbsp;</td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="dllist-__add__"><strong>__add__</strong></a>(...)</dt><dd><tt>x.<a href="#cllist.dllist-__add__">__add__</a>(y)&nbsp;&lt;==&gt;&nbsp;x+y</tt></dd></dl>

<dl><dt><a name="dllist-__contains__"><strong>__contains__</strong></a>(...)</dt><dd><tt>x.<a href="#cllist.dllist-__contains__">__contains__</a>(y)&nbsp;&lt;==&gt;&nbsp;y&nbsp;in&nbsp;x</tt></dd></dl>

<dl><dt><a name="dllist-__delitem__"><strong>__delitem__</strong></a>(...)</dt><dd><tt>x.<a href="#cllist.dllist-__delitem__">__delitem__</a>(y)&nbsp;&lt;==&gt;&nbsp;del&nbsp;x[y]</tt></dd></dl>

<dl><dt><a name="dllist-__eq__"><strong>__eq__</strong></a>(...)</dt><dd><tt>x.<a href="#cllist.dllist-__eq__">__eq__</a>(y)&nbsp;&lt;==&gt;&nbsp;x==y</tt></dd></dl>

<dl><dt><a name="dllist-__ge__"><strong>__ge__</strong></a>(...)</dt><dd><tt>x.<a href="#cllist.dllist-__ge__">__ge__</a>(y)&nbsp;&lt;==&gt;&nbsp;x&gt;=y</tt></dd></dl>

<dl><dt><a name="dllist-__getitem__"><strong>__getitem__</strong></a>(...)</dt><dd><tt>x.<a href="#cllist.dllist-__getitem__">__getitem__</a>(y)&nbsp;&lt;==&gt;&nbsp;x[y]</tt></dd></dl>

<dl><dt><a name="dllist-__getslice__"><strong>__getslice__</strong></a>(...)</dt><dd><tt>x.<a href="#cllist.dllist-__getslice__">__getslice__</a>(i,&nbsp;j)&nbsp;&lt;==&gt;&nbsp;x[i:j]<br>
&nbsp;<br>
Use&nbsp;of&nbsp;negative&nbsp;indices&nbsp;is&nbsp;not&nbsp;supported.</tt></dd></dl>

<dl><dt><a name="dllist-__gt__"><strong>__gt__</strong></a>(...)</dt><dd><tt>x.<a href="#cllist.dllist-__gt__">__gt__</a>(y)&nbsp;&lt;==&gt;&nbsp;x&gt;y</tt></dd></dl>

<dl><dt><a name="dllist-__iadd__"><strong>__iadd__</strong></a>(...)</dt><dd><tt>x.<a href="#cllist.dllist-__iadd__">__iadd__</a>(y)&nbsp;&lt;==&gt;&nbsp;x+=y</tt></dd></dl>

<dl><dt><a name="dllist-__init__"><strong>__init__</strong></a>(...)</dt><dd><tt>x.<a href="#cllist.dllist-__init__">__init__</a>(...)&nbsp;initializes&nbsp;x;&nbsp;see&nbsp;help(type(x))&nbsp;for&nbsp;signature</tt></dd></dl>

<dl><dt><a name="dllist-__iter__"><strong>__iter__</strong></a>(...)</dt><dd><tt>x.<a href="#cllist.dllist-__iter__">__iter__</a>()&nbsp;&lt;==&gt;&nbsp;iter(x)</tt></dd></dl>

<dl><dt><a name="dllist-__le__"><strong>__le__</strong></a>(...)</dt><dd><tt>x.<a href="#cllist.dllist-__le__">__le__</a>(y)&nbsp;&lt;==&gt;&nbsp;x&lt;=y</tt></dd></dl>

<dl><dt><a name="dllist-__len__"><strong>__len__</strong></a>(...)</dt><dd><tt>x.<a href="#cllist.dllist-__len__">__len__</a>()&nbsp;&lt;==&gt;&nbsp;len(x)</tt></dd></dl>

<dl><dt><a name="dllist-__lt__"><strong>__lt__</strong></a>(...)</dt><dd><tt>x.<a href="#cllist.dllist-__lt__">__lt__</a>(y)&nbsp;&lt;==&gt;&nbsp;x&lt;y</tt></dd></dl>

<dl><dt><a name="dllist-__mul__"><strong>__mul__</strong></a>(...)</dt><dd><tt>x.<a href="#cllist.dllist-__mul__">__mul__</a>(n)&nbsp;&lt;==&gt;&nbsp;x*n</tt></dd></dl>

<dl><dt><a name="dllist-__ne__"><strong>__ne__</strong></a>(...)</dt><dd><tt>x.<a href="#cllist.dllist-__ne__">__ne__</a>(y)&nbsp;&lt;==&gt;&nbsp;x!=y</tt></dd></dl>

<dl><dt><a name="dllist-__repr__"><strong>__repr__</strong></a>(...)</dt><dd><tt>x.<a href="#cllist.dllist-__repr__">__repr__</a>()&nbsp;&lt;==&gt;&nbsp;repr(x)</tt></dd></dl>

<dl><dt><a name="dllist-__rmul__"><strong>__rmul__</strong></a>(...)</dt><dd><tt>x.<a href="#cllist.dllist-__rmul__">__rmul__</a>(n)&nbsp;&lt;==&gt;&nbsp;n*x</tt></dd></dl>

<dl><dt><a name="dllist-__setitem__"><strong>__setitem__</strong></a>(...)</dt><dd><tt>x.<a href="#cllist.dllist-__setitem__">__setitem__</a>(i,&nbsp;y)&nbsp;&lt;==&gt;&nbsp;x[i]=y</tt></dd></dl>

<dl><dt><a name="dllist-__str__"><strong>__str__</strong></a>(...)</dt><dd><tt>x.<a href="#cllist.dllist-__str__">__str__</a>()&nbsp;&lt;==&gt;&nbsp;str(x)</tt></dd></dl>

<dl><dt><a name="dllist-append"><strong>append</strong></a>(...)</dt><dd><tt>Append&nbsp;element&nbsp;at&nbsp;the&nbsp;end&nbsp;of&nbsp;the&nbsp;list</tt></dd></dl>

<dl><dt><a name="dllist-appendleft"><strong>appendleft</strong></a>(...)</dt><dd><tt>Append&nbsp;element&nbsp;at&nbsp;the&nbsp;beginning&nbsp;of&nbsp;the&nbsp;list</tt></dd></dl>

<dl><dt><a name="dllist-appendright"><strong>appendright</strong></a>(...)</dt><dd><tt>Append&nbsp;element&nbsp;at&nbsp;the&nbsp;end&nbsp;of&nbsp;the&nbsp;list</tt></dd></dl>

<dl><dt><a name="dllist-clear"><strong>clear</strong></a>(...)</dt><dd><tt>Remove&nbsp;all&nbsp;elements&nbsp;from&nbsp;the&nbsp;list</tt></dd></dl>

<dl><dt><a name="dllist-extend"><strong>extend</strong></a>(...)</dt><dd><tt>Append&nbsp;elements&nbsp;from&nbsp;iterable&nbsp;at&nbsp;the&nbsp;right&nbsp;side&nbsp;of&nbsp;the&nbsp;list</tt></dd></dl>

<dl><dt><a name="dllist-extendleft"><strong>extendleft</strong></a>(...)</dt><dd><tt>Append&nbsp;elements&nbsp;from&nbsp;iterable&nbsp;at&nbsp;the&nbsp;left&nbsp;side&nbsp;of&nbsp;the&nbsp;list</tt></dd></dl>

<dl><dt><a name="dllist-extendright"><strong>extendright</strong></a>(...)</dt><dd><tt>Append&nbsp;elements&nbsp;from&nbsp;iterable&nbsp;at&nbsp;the&nbsp;right&nbsp;side&nbsp;of&nbsp;the&nbsp;list</tt></dd></dl>

<dl><dt><a name="dllist-index"><strong>index</strong></a>(...)</dt><dd><tt>Returns&nbsp;the&nbsp;first&nbsp;index&nbsp;of&nbsp;a&nbsp;value</tt></dd></dl>

<dl><dt><a name="dllist-insert"><strong>insert</strong></a>(...)</dt><dd><tt>Inserts&nbsp;element&nbsp;before&nbsp;node</tt></dd></dl>

<dl><dt><a name="dllist-nodeat"><strong>nodeat</strong></a>(...)</dt><dd><tt>Return&nbsp;node&nbsp;at&nbsp;index</tt></dd></dl>

<dl><dt><a name="dllist-pop"><strong>pop</strong></a>(...)</dt><dd><tt>Remove&nbsp;an&nbsp;element&nbsp;by&nbsp;index&nbsp;from&nbsp;the&nbsp;list&nbsp;and&nbsp;return&nbsp;it,&nbsp;or&nbsp;last&nbsp;item&nbsp;if&nbsp;no&nbsp;index&nbsp;provided</tt></dd></dl>

<dl><dt><a name="dllist-popleft"><strong>popleft</strong></a>(...)</dt><dd><tt>Remove&nbsp;first&nbsp;element&nbsp;from&nbsp;the&nbsp;list&nbsp;and&nbsp;return&nbsp;it</tt></dd></dl>

<dl><dt><a name="dllist-popright"><strong>popright</strong></a>(...)</dt><dd><tt>Remove&nbsp;last&nbsp;element&nbsp;from&nbsp;the&nbsp;list&nbsp;and&nbsp;return&nbsp;it</tt></dd></dl>

<dl><dt><a name="dllist-remove"><strong>remove</strong></a>(...)</dt><dd><tt>Remove&nbsp;element&nbsp;from&nbsp;the&nbsp;list</tt></dd></dl>

<dl><dt><a name="dllist-rindex"><strong>rindex</strong></a>(...)</dt><dd><tt>Returns&nbsp;the&nbsp;last&nbsp;index&nbsp;of&nbsp;a&nbsp;value</tt></dd></dl>

<dl><dt><a name="dllist-rotate"><strong>rotate</strong></a>(...)</dt><dd><tt>Rotate&nbsp;the&nbsp;list&nbsp;n&nbsp;steps&nbsp;to&nbsp;the&nbsp;right</tt></dd></dl>

<hr>
Data descriptors defined here:<br>
<dl><dt><strong>first</strong></dt>
<dd><tt>First&nbsp;node</tt></dd>
</dl>
<dl><dt><strong>last</strong></dt>
<dd><tt>Next&nbsp;node</tt></dd>
</dl>
<dl><dt><strong>middle</strong></dt>
<dd><tt>Middle&nbsp;node</tt></dd>
</dl>
<dl><dt><strong>size</strong></dt>
<dd><tt>Number&nbsp;of&nbsp;elements&nbsp;in&nbsp;the&nbsp;list</tt></dd>
</dl>
<hr>
Data and other attributes defined here:<br>
<dl><dt><strong>__new__</strong> = &lt;built-in method __new__ of type object&gt;<dd><tt>T.<a href="#cllist.dllist-__new__">__new__</a>(S,&nbsp;...)&nbsp;-&gt;&nbsp;a&nbsp;new&nbsp;object&nbsp;with&nbsp;type&nbsp;S,&nbsp;a&nbsp;subtype&nbsp;of&nbsp;T</tt></dl>

</td></tr></table>
</body></html>
Loading