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.51.tar.gz (4.1 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.51-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: jict_dict-0.1.51.tar.gz
  • Upload date:
  • Size: 4.1 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.51.tar.gz
Algorithm Hash digest
SHA256 3c45096750a9af7bd1c184f777e30669e4d08277bdc2add31a5ebd45709471cb
MD5 331242bc31321dfe56695b0d36c2fb46
BLAKE2b-256 f284da7f94956958c0dc7c8fef58a3aaa2ba955eb987a25a9677679fcd3aa547

See more details on using hashes here.

File details

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

File metadata

  • Download URL: jict_dict-0.1.51-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.51-py3-none-any.whl
Algorithm Hash digest
SHA256 33c38bf63d2e4ed101b92fd698b762076225f6c06200660a22be95d4c62dc6db
MD5 11ebe7d48202d08f5e6005aae38cdfe4
BLAKE2b-256 21693502eb9f1340e15c3e22885dd45817c4eb86a9a833fc168f13de67b67621

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