Skip to main content

Your short description here

Project description

JICT

JICT is a bidirectional dictionary that supports reverse lookups and behaves like a standard dict — but with a key difference: it lets you use unhashable keys and values (like lists or dicts), provided you manage them carefully.


🚨 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

  • ✅ Fast reverse lookup via .index(value)
  • ✅ Supports unhashable types (manual conversion required)
  • ✅ Full dict-like API
  • ✅ Custom .copy(), .update(), .fromkeys(), etc.
  • ✅ Optional hash support via ELJIX

Usage

from jict_dict import JICT, ELJIX

j = JICT()

j['a'] = 42
j['b'] = ELJIX.Convert([1, 2, 3])  # manual conversion

print(j['a'])               # 42
print(j.index(42))          # {'a'}
print(j.index(ELJIX.Convert([1, 2, 3])))  # {'b'}

# Use like a normal dict
del j['a']
print('a' in j)             # False
print(list(j.keys))         # ['b']

Time Complexities

🔁 JICT

Operation Time Notes
j[key] O(1) Dict-style access
j[key] = value O(1) Raw value is stored directly
del j[key] O(1) Cleans reverse index
j.index(value) O(1) Requires value to be hashable
j.pop(key) O(1) Removes key + reverse entry
j.popitem() O(1) Removes arbitrary item (KeyError if empty)
j.update(...) O(N) Adds multiple entries
hash(j) O(N × C) Uses ELJIX.Convert(self)
j.copy() O(N) Shallow copy

🔹 C = cost of ELJIX.Convert


🧠 ELJIX

Method Time Description
Convert(obj) O(N) Recursively makes object hashable
Unconvert(obj) O(N) Recovers original structure

API Reference

Class: JICT

Constructor

JICT(initial=None)

Methods

Method Description
add(key, value) Add a key-value pair
remove(key) Remove a key and its reverse entry
pop(key, default) Like dict.pop()
popitem() Like dict.popitem()
clear() Empties both key-value and reverse maps
copy() Returns a shallow copy
get(key, default) Get value or default
setdefault(k, default) Insert if key doesn’t exist
update(other, **kw) Accepts dicts or iterable of pairs
index(value) Returns set of keys for a given value
fromkeys(iterable, v) Like dict.fromkeys()

Properties

Property Description
keys All keys
values All values
items All key-value pairs

Class: ELJIX

Helper class to convert complex/unhashable objects into hashable formats (used mostly for hashing).

Methods

ELJIX.Convert(obj)
ELJIX.Unconvert(obj)
Type Converted To
list tuple
set frozenset
dict frozenset of pairs
tuple recursively converted
other stays the same or becomes id(obj)

Example with Manual Conversion

j = JICT()

data = {'x': [1, 2]}
converted = ELJIX.Convert(data)

j['a'] = converted
print(j.index(converted))  # {'a'}

# Avoid using raw dicts/lists in index() or reverse maps

License

MIT License


Author

Created by ElJeiForeal
Maintained independently.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jict_dict-0.1.6.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jict_dict-0.1.6-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file jict_dict-0.1.6.tar.gz.

File metadata

  • Download URL: jict_dict-0.1.6.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for jict_dict-0.1.6.tar.gz
Algorithm Hash digest
SHA256 6e3aac68086f6ef325aeec18f2c72ac0ec6dfe37a2999d9766ab8b2d68064774
MD5 4deb326a3a5f4f190e4281aab1f04925
BLAKE2b-256 974e92cc7138b8dd5b81a967b1a57a48a1a59a45115cef7582668e9077611e68

See more details on using hashes here.

File details

Details for the file jict_dict-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: jict_dict-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for jict_dict-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 4a3431aa582ea096430ee142e1e4b0b6b258a26492f00b7c7f9a13c3feb09cf1
MD5 d14954f9c5e00602d7a4dcb2003981c7
BLAKE2b-256 5eed1bfdc62bb98d52366859d2e38d337de5d0d483dbe0712f52db5b9b0d90ac

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page