Skip to content

Commit c01d0c4

Browse files
authored
Update homepage for v0.12.1 (#220)
[skip ci]
1 parent 537a9ad commit c01d0c4

File tree

3 files changed

+29
-17
lines changed

3 files changed

+29
-17
lines changed

docs/changelog.md

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

3+
## [0.12.1](https://github.com/tfpf/pysorteddict/compare/v0.12.0...v0.12.1)
4+
5+
<ul class="change-fix">
6+
<li><a href="https://github.com/tfpf/pysorteddict/pull/219">#219</a> Allow using a sorted dictionary even if
7+
importing <code>decimal.Decimal</code> fails.</li>
8+
</ul>
9+
310
## [0.12.0](https://github.com/tfpf/pysorteddict/compare/v0.11.0...v0.12.0)
411

512
<ul class="change-new">

docs/documentation.md

Lines changed: 21 additions & 16 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.12.0](https://github.com/tfpf/pysorteddict/blob/v0.12.0/docs/documentation.md)
78
[0.11.0](https://github.com/tfpf/pysorteddict/blob/v0.11.0/docs/documentation.md)
89
[0.10.0](https://github.com/tfpf/pysorteddict/blob/v0.10.0/docs/documentation.md)
910
[0.9.0](https://github.com/tfpf/pysorteddict/blob/v0.9.0/docs/documentation.md)
@@ -39,41 +40,45 @@ or implicitly using the wildcard (though this is not recommended).
3940
from pysorteddict import *
4041
```
4142

42-
The following key types are supported.
43+
The following key types are always supported.
4344

4445
* `bytes`
4546
* `float`
4647
* `int`
4748
* `str`
48-
* `decimal.Decimal`
4949

50-
### Constructor
50+
The following key types are supported if they are importable (which they should always be—failure to import them may be
51+
a sign of a corrupt or damaged Python installation).
5152

52-
#### `SortedDict(*args, **kwargs) -> SortedDict`
53-
54-
Create an empty sorted dictionary. `args` and `kwargs` are ignored.
53+
* `decimal.Decimal`
5554

5655
<details class="warning">
5756

58-
<summary>This method may raise exceptions.</summary>
59-
60-
If any of the supported key types which are not built-in (only `decimal.Decimal` as of this version) cannot be imported
61-
(which might be a symptom of a corrupt or damaged Python installation), raises `ImportError`.
57+
<summary>Shadowing these standard library types with custom types may lead to undefined behaviour.</summary>
6258

6359
```python
60+
from pathlib import Path
61+
with Path(__file__).with_name("decimal.py").open("w") as writer:
62+
print("import math", file=writer)
63+
print('Decimal = type("Decimal", (float,), {"is_nan": lambda self: math.isnan(self)})', file=writer)
6464
from pysorteddict import *
65+
from decimal import Decimal
6566
d = SortedDict()
67+
d[Decimal(0)] = None
6668
```
6769

68-
```text
69-
Traceback (most recent call last):
70-
File "…", line 2, in <module>
71-
d = SortedDict()
72-
ImportError: failed to import the `decimal.Decimal` type
73-
```
70+
Here, the imported `Decimal` is actually `float` with an `is_nan` method defined. This will work. However, comparisons
71+
between two such `Decimal`s can be made to error out (by overriding `Decimal.__eq__` and friends). Errors in the
72+
comparator of a C++ `std::map` (the underlying type of a sorted dictionary) invoke undefined behaviour.
7473

7574
</details>
7675

76+
### Constructor
77+
78+
#### `SortedDict(*args, **kwargs) -> SortedDict`
79+
80+
Create an empty sorted dictionary. `args` and `kwargs` are ignored.
81+
7782
### Properties
7883

7984
#### `d.key_type: type | None`

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ docs = ["furo~=2024.8", "myst-parser~=4.0"]
1111

1212
[project]
1313
name = "pysorteddict"
14-
version = "0.12.0"
14+
version = "0.12.1"
1515
authors = [
1616
{name = "Vishal Pankaj Chandratreya"},
1717
]

0 commit comments

Comments
 (0)