Registry / data / winrt-windows-foundation-collections

winrt-windows-foundation-collections

JSON →
library3.2.1pypypiunverified

This package provides Python projections for the Windows Runtime (WinRT) APIs specifically within the `Windows.Foundation.Collections` namespace. It enables Python developers to interact with WinRT collection types like maps, vectors, and property sets. The current version is 3.2.1, with releases occurring frequently, often tied to Windows SDK updates and bug fixes.

pip install winrt-windows-foundation-collections
INSTALL
IMPORT
SIG · WINRT-WINDOWS-FOUN
W
winrt-windows-foundation-collections
datapythonv3.2.1
Install
Import
Disk
Pass rate
0/ 10
Env Coverage0 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v? · pip install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
build_error
glibc
py 3.103.910 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

IVector
from winrt.windows.foundation.collections import IVector
from winrt.foundation.collections import IVector
The full namespace path `winrt.windows.foundation.collections` must be used, not `winrt.foundation.collections`.
IMap
from winrt.windows.foundation.collections import IMap
from winrt.runtime.collections import IMap
WinRT types are organized by their full WinRT namespace within the `winrt` Python package hierarchy.
PropertySet
from winrt.windows.foundation.collections import PropertySet

This quickstart demonstrates creating and interacting with a `PropertySet`, a common mutable WinRT map-like collection. It shows how to insert items, retrieve them, and iterate over the collection using both WinRT-specific methods and Python's dictionary-like interface.

from winrt.windows.foundation.collections import PropertySet from winrt.windows.foundation import Uri # PropertySet is a concrete WinRT collection type (IMap<str, object>) properties = PropertySet() properties.Insert("myString", "Hello WinRT") properties.Insert("myNumber", 123) properties.Insert("myUri", Uri("http://example.com/test")) print(f"PropertySet size: {properties.Size}") print(f"Value for 'myString': {properties.Lookup('myString')}") print(f"Value for 'myUri': {properties.Lookup('myUri')}") # PropertySet also supports Python dictionary-like access and iteration properties["anotherKey"] = "anotherValue" print("\nIterating through PropertySet:") for key, value in properties: print(f" {key}: {value}") # Check if a key exists if properties.HasKey("myNumber"): print(f"'myNumber' exists with value: {properties['myNumber']}")
Debug
Known issues
breakingVersion 3.0.0 introduced significant breaking changes, including a new `winrt.runtime` module, changes to object identity (`==`, `hash()`), and interface casting (`as_()`).
fix
Consult the official migration guide for `pywinrt` version 2 to 3 (often found in the project's GitHub repository under `scripts/2to3/README.md`) to adapt your code.
affects: >=3.0.0
breakingThe `winrt-windows-foundation-collections==2.0.0` package was never published to PyPI due to compilation issues, despite being tagged in GitHub. Attempts to install this specific version will fail.
fix
Do not target version `2.0.0`. Use `2.0.1` or later, as `2.0.1` contains fixes and was successfully published.
affects: 2.0.0
breakingPrior to version 3.1.0, `IIterator.__iter__()` returned an invalid object or did not take a reference, leading to crashes or broken Pythonic iteration (e.g., `for item in my_collection:`).
fix
Upgrade to `winrt-windows-foundation-collections` version 3.1.0 or newer to ensure correct iteration behavior for WinRT collections.
affects: <3.1.0
gotchaAs of version 3.2.0, `asyncio` cancellation is propagated to WinRT async actions/operations. If your code relies on WinRT operations continuing after an `asyncio` task is cancelled, this behavior change might affect you.
fix
Review `asyncio` task cancellation logic when awaiting WinRT async operations. If previous cancellation behavior was implicitly relied upon, you might need to adjust task handling or error recovery.
affects: >=3.2.0
Upgrade
Version history
3.2.1latest on PyPI · released Jun 6, 2025
Audit
Dependencies
winrt-runtimerequiredProvides the core WinRT projection engine and base types.
winrt-windows-foundationrequiredProvides types from the Windows.Foundation namespace, which collections often rely on.
Agent activity
27 hits · last 30 days
node
22
OpenAI (training)
1
Resources
winrt-windows-foundation-collections — pip install winrt-windows-foundation-collections · libregistry