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 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

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 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.4.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.4-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: jict_dict-0.1.4.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.4.tar.gz
Algorithm Hash digest
SHA256 962fbbf4a68998df13fc06d0984d9244f0b5a555d262d751cad9d6c6d113762d
MD5 233b46cc0f66c02eac880ed1d8e8e94f
BLAKE2b-256 9991a33a50b2c112458ecd79bfe457d6f163b89023d7a8497b4e380a0379caec

See more details on using hashes here.

File details

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

File metadata

  • Download URL: jict_dict-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 4.1 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 d78e377b28e97f92442f5699784b2aed849572a21b821f97b86dc89dea5100e9
MD5 c7781b75eb2965c16c03b59b4b05cc3c
BLAKE2b-256 12cb73bda3ad940611d9e8df025fae2d8fb745345099376c780748b1bc1fcc78

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