Skip to content

Commit 7ef3d4c

Browse files
authored
Update homepage for v0.10.0 [skip ci] (#189)
1 parent 390757f commit 7ef3d4c

File tree

5 files changed

+95
-22
lines changed

5 files changed

+95
-22
lines changed

docs/changelog.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
11
# Changelog
22

3+
## [0.10.0](https://github.com/tfpf/pysorteddict/compare/v0.9.0...v0.10.0)
4+
5+
<ul class="change-new">
6+
<li><a href="https://github.com/tfpf/pysorteddict/pull/184">#184</a> Define <code>SortedDictValues</code> as a view
7+
over the values of a sorted dictionary. Define <code>SortedDictValues.__repr__</code>,
8+
<code>SortedDictValues.__len__</code>, <code>SortedDictValues.__getitem__</code> and
9+
<code>SortedDictValues.__iter__</code>. Define <code>SortedDictValuesIter</code> as an iterator over the values of a
10+
sorted dictionary. Define <code>SortedDictValuesIter.__iter__</code> and <code>SortedDictValuesIter.__next__</code>.
11+
Update <code>SortedDict.values</code> to return the aforementioned view.</li>
12+
<li><a href="https://github.com/tfpf/pysorteddict/pull/187">#187</a> Define <code>SortedDictItems</code> as a view
13+
over the items of a sorted dictionary. Define <code>SortedDictItems.__repr__</code>,
14+
<code>SortedDictItems.__len__</code>, <code>SortedDictItems.__getitem__</code> and
15+
<code>SortedDictItems.__iter__</code>. Define <code>SortedDictItemsIter</code> as an iterator over the items of a
16+
sorted dictionary. Define <code>SortedDictItemsIter.__iter__</code> and <code>SortedDictItemsIter.__next__</code>.
17+
Update <code>SortedDict.items</code> to return the aforementioned view.</li>
18+
</ul>
19+
320
## [0.9.0](https://github.com/tfpf/pysorteddict/compare/v0.8.2...v0.9.0)
421

522
<ul class="change-new">

docs/documentation.md

Lines changed: 61 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
<summary>Documentation of older versions is available on GitHub.</summary>
66

7+
[0.9.0](https://github.com/tfpf/pysorteddict/blob/v0.9.0/docs/documentation.md)
78
[0.8.2](https://github.com/tfpf/pysorteddict/blob/v0.8.2/docs/documentation.md)
89
[0.8.1](https://github.com/tfpf/pysorteddict/blob/v0.8.1/docs/documentation.md)
910
[0.8.0](https://github.com/tfpf/pysorteddict/blob/v0.8.0/docs/documentation.md)
@@ -527,10 +528,29 @@ Uncommenting the commented line runs any required destructors and makes this err
527528

528529
Return a shallow copy of the sorted dictionary `d`.
529530

530-
#### `d.items() -> list[tuple[object, object]]`
531+
#### `d.items() -> SortedDictItems`
531532

532-
Return the key-value pairs in the sorted dictionary `d`. The list will be sorted. It will exist independently of `d`;
533-
it won't be a view on its items.
533+
Return a dynamic view on the items in the sorted dictionary `d`.
534+
535+
```python
536+
from pysorteddict import *
537+
d = SortedDict()
538+
items = d.items()
539+
d["foo"] = ()
540+
print(items)
541+
d["bar"] = [100]
542+
print(items)
543+
d["baz"] = 3.14
544+
print(items)
545+
```
546+
547+
```text
548+
SortedDictItems([('foo', ())])
549+
SortedDictItems([('bar', [100]), ('foo', ())])
550+
SortedDictItems([('bar', [100]), ('baz', 3.14), ('foo', ())])
551+
```
552+
553+
See [sorted dictionary views](#sorted-dictionary-views).
534554

535555
#### `d.keys() -> SortedDictKeys`
536556

@@ -554,21 +574,42 @@ SortedDictKeys(['bar', 'foo'])
554574
SortedDictKeys(['bar', 'baz', 'foo'])
555575
```
556576

557-
See the documentation of [sorted dictionary views](#sorted-dictionary-views).
577+
See [sorted dictionary views](#sorted-dictionary-views).
578+
579+
#### `d.values() -> SortedDictValues`
558580

559-
#### `d.values() -> list[object]`
581+
Return a dynamic view on the values in the sorted dictionary `d`.
560582

561-
Return the values in the sorted dictionary `d`. The list will be sorted by the keys the values are mapped to. It will
562-
exist independently of `d`; it won't be a view on its values.
583+
```python
584+
from pysorteddict import *
585+
d = SortedDict()
586+
values = d.values()
587+
d["foo"] = ()
588+
print(values)
589+
d["bar"] = [100]
590+
print(values)
591+
d["baz"] = 3.14
592+
print(values)
593+
```
594+
595+
```text
596+
SortedDictValues([()])
597+
SortedDictValues([[100], ()])
598+
SortedDictValues([[100], 3.14, ()])
599+
```
600+
601+
See [sorted dictionary views](#sorted-dictionary-views).
563602

564603
## Sorted Dictionary Views
565604

566605
Sorted dictionary views are dynamic views on a sorted dictionary: they are immutable and cannot be used to mutate the
567606
sorted dictionary, but always reflect its current state.
568607

569-
As of the current version, there is only one view type.
608+
There are three view types:
570609

571-
* `SortedDictKeys`: the return type of `SortedDict.keys`.
610+
* `SortedDictItems`, the return type of [`SortedDict.items`](#ditems---sorteddictitems);
611+
* `SortedDictKeys`, the return type of [`SortedDict.keys`](#dkeys---sorteddictkeys); and
612+
* `SortedDictValues`, the return type of [`SortedDict.values`](#dvalues---sorteddictvalues).
572613

573614
### Magic Methods
574615

@@ -601,26 +642,28 @@ like when slicing a `list`.
601642
```python
602643
from pysorteddict import *
603644
d = SortedDict()
604-
keys = d.keys()
645+
items, keys, values = d.items(), d.keys(), d.values()
605646
d["foo"] = ()
606647
d["bar"] = [100]
607648
d["baz"] = 3.14
608649
d["spam"] = {}
609650
d["eggs"] = ""
610-
print(keys[0], keys[2], keys[4])
651+
print(d)
652+
print(keys[0], keys[2], values[4])
611653
print(keys[:3])
612-
print(keys[1:])
613-
print(keys[-3:3])
614-
print(keys[-5:4:2])
654+
print(items[1:])
655+
print(values[-3:3])
656+
print(items[-5:4:2])
615657
print(keys[::-1])
616658
```
617659

618660
```text
619-
bar eggs spam
661+
SortedDict({'bar': [100], 'baz': 3.14, 'eggs': '', 'foo': (), 'spam': {}})
662+
bar eggs {}
620663
['bar', 'baz', 'eggs']
621-
['baz', 'eggs', 'foo', 'spam']
622-
['eggs']
623-
['bar', 'eggs']
664+
[('baz', 3.14), ('eggs', ''), ('foo', ()), ('spam', {})]
665+
['']
666+
[('bar', [100]), ('eggs', '')]
624667
['spam', 'foo', 'eggs', 'baz', 'bar']
625668
```
626669

docs/source_code.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,24 @@ Implementation of the Python `SortedDict` type.
1616

1717
### `sorted_dict_view_type.cc`
1818

19-
Implementation of views over `SortedDict` objects—superclasses of `SortedDictKeys` and `SortedDictKeysIter`.
19+
Implementation of views over `SortedDict` objects—superclasses of `SortedDictItems`, `SortedDictItemsIter`,
20+
`SortedDictKeys`, `SortedDictKeysIter`, `SortedDictValues` and `SortedDictValuesIter`.
21+
22+
### `sorted_dict_items_type.cc`
23+
24+
Implementation of the Python `SortedDictItems` and `SortedDictItemsIter` types. Exposed to users only indirectly via
25+
`SortedDict.items`.
2026

2127
### `sorted_dict_keys_type.cc`
2228

2329
Implementation of the Python `SortedDictKeys` and `SortedDictKeysIter` types. Exposed to users only indirectly via
2430
`SortedDict.keys`.
2531

32+
### `sorted_dict_values_type.cc`
33+
34+
Implementation of the Python `SortedDictValues` and `SortedDictValuesIter` types. Exposed to users only indirectly via
35+
`SortedDict.values`.
36+
2637
### `sorted_dict_module.cc`
2738

2839
Implementation of the Python `pysorteddict` module. Glue between Python methods and C++ methods.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ build-backend = "setuptools.build_meta"
88

99
[project]
1010
name = "pysorteddict"
11-
version = "0.9.0"
11+
version = "0.10.0"
1212
authors = [
1313
{name = "Vishal Pankaj Chandratreya"},
1414
]

src/pysorteddict/sorted_dict_module.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,9 @@ static PyTypeObject sorted_dict_type = {
547547
.tp_hash = PyObject_HashNotImplemented,
548548
.tp_getattro = PyObject_GenericGetAttr,
549549
.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_DICT_SUBCLASS,
550-
.tp_doc = "Sorted dictionary: a dictionary in which the keys are always in ascending order.",
550+
.tp_doc = "Sorted dictionary: a dictionary in which the keys are always in ascending order.\n\n"
551+
"SortedDict(*args, **kwargs) -> SortedDict\n"
552+
"Create an empty sorted dictionary. ``args`` and ``kwargs`` are ignored.",
551553
.tp_iter = sorted_dict_type_iter,
552554
.tp_methods = sorted_dict_type_methods,
553555
.tp_getset = sorted_dict_type_getset,
@@ -560,7 +562,7 @@ static PyTypeObject sorted_dict_type = {
560562
static PyModuleDef sorted_dict_module = {
561563
.m_base = PyModuleDef_HEAD_INIT,
562564
.m_name = "pysorteddict",
563-
.m_doc = "Enriches Python with a sorted dictionary.\n\nSee https://tfpf.github.io/pysorteddict/.",
565+
.m_doc = "enriches Python with a sorted dictionary\n\nSee https://tfpf.github.io/pysorteddict/.",
564566
.m_size = -1,
565567
};
566568

0 commit comments

Comments
 (0)