Your short description here
Project description
JICT DICT
JICT is a bidirectional dictionary with superpowers. It behaves like a normal Python dict, but with advanced features like reverse lookup, support for unhashable keys/values, and a fully extendable API — making it great for advanced data mapping, indexing, and transformation tasks.
🆚 Why Use JICT Over dict?
Here’s what JICT can do that regular dict cannot:
1. 🔁 Reverse Lookup
With JICT, you can instantly find all keys that map to a given value using .index(value) — something a regular dict does not support without looping.
from jict_dict import JICT
j = JICT()
j['x'] = 10
j['y'] = 10
j['z'] = 5
print(j.index(10)) # {'x', 'y'}
print(j.index(5)) # {'z'}
2. 🧩 Use Unhashable Keys/Values (manually converted)
Regular dict requires all keys to be hashable. JICT supports unhashable types like list, dict, and set — as long as you manually convert them using ELJIX.Convert().
from jict_dict import JICT, ELJIX
j = JICT()
data = {'a': [1, 2]}
key = ELJIX.Convert(data)
j[key] = "stored!"
print(j[key]) # "stored!"
print(j.index("stored!")) # {converted key}
✅ This allows you to safely use complex data structures as keys or values — something normal
dicts will reject withTypeError.
3. 💥 True Bidirectional Mapping
When you assign a value, JICT tracks both key → value and value → key automatically, meaning .index() is always up-to-date.
If you delete or update keys, the reverse mappings are cleaned up too:
j = JICT()
j['a'] = 1
j['b'] = 1
print(j.index(1)) # {'a', 'b'}
del j['a']
print(j.index(1)) # {'b'}
🚨 Important Note on Unhashables
JICT does not automatically convert unhashable types for you.
If you want to use list, dict, or set as keys or values in any context that requires hashing (e.g., reverse lookup or hashing the entire object), you must manually convert them using ELJIX.Convert().
from jict_dict import JICT, ELJIX
j = JICT()
val = {'a': [1, 2]}
conv_val = ELJIX.Convert(val)
j['key'] = conv_val
print(j.index(conv_val)) # Works
📦 Installation
pip install jict_dict
🔧 Features Summary
- ✅ Reverse lookup:
j.index(value)returns all keys for a value. - ✅ Supports unhashable keys/values with
ELJIX.Convert(). - ✅ Custom
dictAPI with.fromkeys(),.update(),.copy(), etc. - ✅ Fast and safe key/value management.
- ✅ Optional full-object hashing via
ELJIX.
🧪 Real-World Examples
🔍 Group keys by values (reverse lookup)
j = JICT()
j['admin'] = 'group1'
j['bob'] = 'group2'
j['alice'] = 'group1'
print(j.index('group1')) # {'admin', 'alice'}
🧬 Hash unhashable objects
from jict_dict import ELJIX
data = {'x': [1, 2, 3]}
converted = ELJIX.Convert(data)
print(hash(converted)) # safe!
original = ELJIX.Unconvert(converted)
print(original) # [1, 2, {'x': 3}]
🧼 Safe Deletion Keeps Index Clean
j = JICT()
j['foo'] = 123
j['bar'] = 123
print(j.index(123)) # {'foo', 'bar'}
j.pop('foo')
print(j.index(123)) # {'bar'}
⚙️ Initialize with Converted Input
from jict_dict import JICT, ELJIX
initial = {
"sword": "meele",
"bow": "ranged",
"fists": "meele"
}
j = JICT(initial)
print(j.index("meele")) # {'sword', 'fists'}
✨ Cleaner Code
from jict_dict import JICT, ELJIX
RawItems = JICT({
"sword": "melee",
"bow": "ranged",
"fists": "melee",
})
RawArmor = JICT({
"iron": "chestplate",
"gold": "chestplate",
})
# Convert JICT instances to hashable versions
Items = ELJIX.Convert(RawItems)
Armor = ELJIX.Convert(RawArmor)
# Store converted objects inside another JICT
Inventory = JICT({
"Armor": Armor,
"Items": Items,
})
# Unconvert 'Armor' to get back a JICT instance, then do reverse lookup
armor_obj = ELJIX.Unconvert(Inventory["Armor"])
print(armor_obj.index("chestplate")) # Output: {'iron', 'gold'}
⏱ Time Complexities
JICT
| Operation | Time | Description |
|---|---|---|
j[key] |
O(1) | Dict-style access |
j[key] = value |
O(1) | Stores value and updates reverse map |
j.index(value) |
O(1) | Reverse lookup (set of keys) |
del j[key] |
O(1) | Removes key and cleans reverse map |
j.copy() |
O(N) | Shallow copy |
update() |
O(N) | Batch insert |
hash(j) |
O(N×C) | With ELJIX.Convert (if used) |
C= cost of converting a value withELJIX
ELJIX
| Method | Time | Description |
|---|---|---|
Convert(obj) |
O(N) | Recursively converts to hashable |
Unconvert(obj) |
O(N) | Recovers original data |
🧠 ELJIX: Hashable Conversion
ELJIX is a utility class to make anything hashable — even if it's a list or dictionary.
Conversion Types
| Type | Converted To |
|---|---|
list |
tuple |
dict |
frozenset of key-value pairs |
set |
frozenset |
tuple |
Recursively converted |
other |
Left as-is (or fallback hash) |
x = [1, 2, {"a": 3}]
converted = ELJIX.Convert(x)
print(hash(converted)) # safe!
original = ELJIX.Unconvert(converted)
print(original) # [1, 2, {'a': 3}]
🧩 API Overview
Class: JICT
| Method | Description |
|---|---|
add(k, v) |
Add key-value pair |
remove(k) |
Remove key and reverse entry |
index(v) |
Get set of keys for value |
get(k, default) |
Like dict.get() |
setdefault(k, d) |
Set default if key not found |
update(...) |
Add multiple key-value pairs |
copy() |
Shallow copy |
clear() |
Remove all items |
fromkeys(iter, v) |
Like dict.fromkeys() |
pop(k) |
Remove key and return value |
popitem() |
Remove & return arbitrary item |
Properties
| Property | Description |
|---|---|
keys |
All keys (like dict) |
values |
All values |
items |
Key-value pairs |
🛠 Compatibility
- ✅ Python 3.6+
- ✅ No external dependencies
- ✅ Cross-platform
- ✅ Lightweight (~2KB installed)
🔐 License
MIT License
👤 Author
Created and maintained by ElJeiForeal
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jict_dict-0.2.12.tar.gz.
File metadata
- Download URL: jict_dict-0.2.12.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c66bc63fce85e3c24f16efa46b38997714dd09c9089a18ccc77ec329dcbcfcd5
|
|
| MD5 |
f5191a33c9ca36b81641f00d2ff8d21f
|
|
| BLAKE2b-256 |
3d0aa376eb190a4d4ae067b2aa29d057266b1b35a0d2b3c4bce0bc3d782a0604
|
File details
Details for the file jict_dict-0.2.12-py3-none-any.whl.
File metadata
- Download URL: jict_dict-0.2.12-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7b6dab73abe576bfa91724211314614ee0cf62dd19897fba32a493043631fbc9
|
|
| MD5 |
684c6f191fd1e16773a7b912fadb3b85
|
|
| BLAKE2b-256 |
1eaebc5a4b9cf8bd98bfdb502c53fe6fac96dd0be955dd7894d32d8b13b61eb7
|