Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor py3 #23

Merged
merged 9 commits into from
Jul 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions .github/workflows/package_lint-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ on:
jobs:
build:

runs-on: ubuntu-latest
runs-on: ubuntu-20.04 # py36 is EOL on ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "pypy3.9"]
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "pypy3.9"]

steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 0 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ Priority Queue Dictionary (pqdict)

A priority queue dictionary maps hashable objects (keys) to priority-determining values. It provides a hybrid dictionary/priority queue API.

Works with Python 2.7+, 3.4+, and PyPy.

.. image:: https://github.com/nvictus/priority-queue-dictionary/actions/workflows/package_lint-test.yml/badge.svg
:target: https://github.com/nvictus/priority-queue-dictionary/actions/workflows/package_lint-test.yml
:alt: CI
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def _get_version():
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
language = "en"

# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
Expand Down
56 changes: 34 additions & 22 deletions docs/pqdict.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ pqdict class
.. autoclass:: pqdict
:no-members:

.. automethod:: fromkeys
.. automethod:: minpq

.. automethod:: heapify([key])
.. automethod:: maxpq

.. automethod:: fromkeys

|

Expand Down Expand Up @@ -44,9 +46,14 @@ pqdict class

.. method:: pop([key[, default]])

If ``key`` is in the pqdict, remove it and return its priority value,
else return ``default``. If ``default`` is not provided and ``key`` is
not in the pqdict, raise a ``KeyError``.
Hybrid pop method.

With ``key``, perform a dictionary pop:

* If ``key`` is in the pqdict, remove the item and return its
**value**.
* If ``key`` is not in the pqdict, return ``default`` if provided,
otherwise raise a ``KeyError``.

.. automethod:: clear

Expand All @@ -59,7 +66,9 @@ pqdict class
Iterators and Views

.. warning::
For the following sequences, order is arbitrary.
For the sequences returned by the following methods, the **iteration order is arbitrary**.

See further below for sorted iterators :meth:`popkeys`, :meth:`popvalues`, and :meth:`popitems`.

.. method:: iter(pq)

Expand All @@ -69,53 +78,56 @@ pqdict class

.. automethod:: items

.. note::
In Python 2, the above methods return lists rather than views and ``pqdict`` includes additional iterator methods ``iterkeys()``, ``itervalues()`` and ``iteritems()``.

|

**Priority Queue API**

.. automethod:: top

.. automethod:: topvalue

.. automethod:: topitem

.. method:: pop([key[, default]])
.. method:: pop(*, [default])

If ``key`` is not provided, remove the top item and return its key, or
raise ``KeyError`` if the pqdict is empty.
Hybrid pop method.

.. automethod:: additem
Without ``key``, perform a priority queue pop:

.. automethod:: updateitem

.. automethod:: topitem
* Remove the top item and return its **key**.
* If the pqdict is empty, return ``default`` if provided, otherwise
raise a ``KeyError``.

.. automethod:: popvalue

.. automethod:: popitem

.. automethod:: additem

.. automethod:: updateitem

.. automethod:: pushpopitem(key, value)

.. automethod:: replace_key

.. automethod:: swap_priority

Heapsort Iterators
.. automethod:: heapify([key])

Sorted Iterators

.. note::
Iteration is in descending order of priority.

.. danger::
Heapsort iterators are destructive: they are generators that pop items out of the heap, which amounts to performing a heapsort.
.. warning::
Sorted iterators are destructive: they are generators that pop items out of the heap, which amounts to performing a heapsort.

.. automethod:: popkeys

.. automethod:: popvalues

.. automethod:: popitems

.. warning::
The names of the heapsort iterators in v0.5 (iterkeys, itervalues, iteritems) were changed in v0.6 to be more transparent: These names are not provided at all in Python 3, and in Python 2 they are now part of the dictionary API.


Functions
---------
Expand Down
Loading