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

Uploaded Python 3

File details

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

File metadata

  • Download URL: jict_dict-0.1.5.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.5.tar.gz
Algorithm Hash digest
SHA256 e0fd2db3c7de6dabf76cabc57cd7c90207f1b89d666299ef01ef92b1da43fdd2
MD5 90254e70aad6d667d74581a795af2a70
BLAKE2b-256 f5759081db1774ca7f3b59755e3fc900eed3bb828a283bb855e3d3788c2fc66e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: jict_dict-0.1.5-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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 059a2d9c1c3ff11aa4429c8ac20b59cd71157a7dedab06f3fd78bdb1419ef559
MD5 1121cdfbb340e7ca9d31a1147b5a31c1
BLAKE2b-256 e1793e913a2c8ba4fa28b7bfb477f8a47426b50dca0ac53d772fcf39d5812b4f

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