javapy 2.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
javapy-2.0.0/PKG-INFO ADDED
@@ -0,0 +1,18 @@
1
+ Metadata-Version: 2.4
2
+ Name: javapy
3
+ Version: 2.0.0
4
+ Summary: Paket Python berperforma tinggi tanpa dependensi eksternal
5
+ Home-page: https://github.com/Eternals-Satya/javapy
6
+ Author: Eternals
7
+ Author-email: Eternals <eternals.tolong@gmail.com>
8
+ Project-URL: Homepage, https://github.com/Eternals-Satya/javapy
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Requires-Python: >=3.7
13
+ Description-Content-Type: text/markdown
14
+ Dynamic: author
15
+ Dynamic: home-page
16
+ Dynamic: requires-python
17
+
18
+ # javapy
javapy-2.0.0/README.md ADDED
@@ -0,0 +1 @@
1
+ # javapy
@@ -0,0 +1,24 @@
1
+ from .highspeed.database import SQLiteHighSpeed
2
+ from .highspeed.cache import MemoryCache
3
+ from .highspeed.serializer import pack_data, unpack_data
4
+ from .highspeed.threader import ThreadPool
5
+ from .utils.memory import MemoryProfiler
6
+ from .utils.compress import compress, decompress
7
+
8
+ __version__ = "2.0.0"
9
+ __all__ = [
10
+ 'SQLiteHighSpeed',
11
+ 'MemoryCache',
12
+ 'pack_data',
13
+ 'unpack_data',
14
+ 'ThreadPool',
15
+ 'MemoryProfiler',
16
+ 'compress',
17
+ 'decompress'
18
+ ]
19
+
20
+ # Optimasi import
21
+ def __getattr__(name):
22
+ if name in __all__:
23
+ return globals()[name]
24
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
@@ -0,0 +1,37 @@
1
+ import cython
2
+ from time import time
3
+ from typing import Any, Dict, Optional
4
+
5
+ @cython.cclass
6
+ class MemoryCache:
7
+ _store: dict
8
+ _ttl: dict
9
+
10
+ def __init__(self):
11
+ self._store = {}
12
+ self._ttl = {}
13
+
14
+ @cython.ccall
15
+ def set(self, key: str, value: Any, ttl: int = 60) -> None:
16
+ self._store[key] = value
17
+ self._ttl[key] = time() + ttl
18
+
19
+ @cython.ccall
20
+ def get(self, key: str) -> Optional[Any]:
21
+ if key in self._store and time() < self._ttl.get(key, 0):
22
+ return self._store[key]
23
+ return None
24
+
25
+ @cython.ccall
26
+ def purge(self) -> None:
27
+ current = time()
28
+ expired = [k for k, v in self._ttl.items() if v < current]
29
+ for k in expired:
30
+ del self._store[k]
31
+ del self._ttl[k]
32
+
33
+ @cython.ccall
34
+ def clear(self) -> None:
35
+ """Bersihkan seluruh cache"""
36
+ self._store.clear()
37
+ self._ttl.clear()