<div align="center">
# 🚀 py-readonlyx
**Lightweight Python Read-Only Property Decorator**
*Periyodik görevlerinizi kolayca yönetin - Sıfır bağımlılık, maksimum performans*




[](https://github.com/yourusername/py-readonlyx)
[](https://github.com/yourusername/py-readonlyx)
[](https://github.com/yourusername/py-readonlyx)
</div>
---
## 📖 Genel Bakış
**py-readonlyx**, Python sınıflarında read-only (salt okunur) property'ler oluşturmak için tasarlanmış minimal ve yüksek performanslı bir decorator kütüphanesidir. Sadece **tek bir decorator** ile property'lerinizi değiştirilemez hale getirebilirsiniz.
## 🎯 Neden py-readonlyx?
### 🆚 Diğer Çözümlerle Karşılaştırma
| Özellik | py-readonlyx | Manuel Property | dataclasses.frozen | attrs.frozen |
|---------|--------------|-----------------|-------------------|--------------|
| **Basitlik** | ✅ Tek decorator | ❌ Çok kod | ⚠️ Sınıf seviyesi | ⚠️ Bağımlılık |
| **Performans** | ✅ Yüksek | ✅ Yüksek | ⚠️ Orta | ⚠️ Orta |
| **Bağımlılık** | ✅ Sıfır | ✅ Sıfır | ✅ Stdlib | ❌ Dış paket |
| **Seçici Control** | ✅ Property bazlı | ✅ Property bazlı | ❌ Tüm sınıf | ❌ Tüm sınıf |
| **Mutable Fields** | ✅ Destekler | ✅ Destekler | ❌ Desteklemez | ❌ Desteklemez |
### 💡 Neden Bu Kütüphaneyi Seçmelisiniz?
- **🏃♂️ Sıfır Öğrenme Eğrisi**: Sadece `@readonly` ekleyin, hazır!
- **⚡ Yüksek Performans**: Native Python property'lerinin performansı
- **🪶 Sıfır Bağımlılık**: Harici paket gerektirmez
- **🎛️ Granüler Kontrol**: Sadece istediğiniz property'leri readonly yapın
- **🔄 Karma Kullanım**: Aynı sınıfta readonly ve normal property'ler
- **🧵 Thread-Safe**: Çoklu thread ortamlarında güvenli
- **📦 Minimal Footprint**: Toplam ~50 satır kod
## 🚀 Hızlı Başlangıç
### Kurulum
```bash
# Bu projeyi klonlayın
git clone https://github.com/yourusername/py-readonlyx.git
cd py-readonlyx
# Python path'inize ekleyin veya doğrudan import edin
```
### Temel Kullanım
```python
from py_readonlyx import readonly, ReadOnlyError
class User:
def __init__(self, name="Fırat", age=25):
self._name = name
self._age = age
self._status = "active" # Bu değiştirilebilir
@readonly
def name(self):
"""Kullanıcı adı - salt okunur"""
return self._name
@readonly
def age(self):
"""Kullanıcı yaşı - salt okunur"""
return self._age
# Normal property - değiştirilebilir
@property
def status(self):
return self._status
@status.setter
def status(self, value):
self._status = value
# Kullanım
user = User("Ahmet", 30)
# ✅ Okuma işlemleri
print(user.name) # "Ahmet"
print(user.age) # 30
# ✅ Normal property değişikliği
user.status = "inactive" # Çalışır
# ❌ Read-only property değişikliği
user.name = "Mehmet" # ReadOnlyError
user.age = 35 # ReadOnlyError
del user.name # ReadOnlyError
```
## 🛠️ Gelişmiş Kullanım
### API Referansı
#### `@readonly` Decorator
Property'yi salt okunur hale getirir.
```python
@readonly
def property_name(self):
return self._value
```
#### `ReadOnlyError` Exception
Read-only property'ye yazma/silme girişiminde fırlatılır.
```python
try:
user.readonly_prop = "new_value"
except ReadOnlyError as e:
print(f"Hata: {e}")
# "Cannot set read-only property 'readonly_prop'"
```
### Kullanım Senaryoları
#### 1. Immutable Model Classes
```python
class Point:
def __init__(self, x, y):
self._x, self._y = x, y
@readonly
def x(self): return self._x
@readonly
def y(self): return self._y
```
#### 2. Configuration Objects
```python
class Config:
def __init__(self, api_key, database_url):
self._api_key = api_key
self._database_url = database_url
@readonly
def api_key(self): return self._api_key
@readonly
def database_url(self): return self._database_url
```
#### 3. Computed Properties
```python
class Circle:
def __init__(self, radius):
self._radius = radius
@property
def radius(self): return self._radius
@radius.setter
def radius(self, value): self._radius = value
@readonly
def area(self): return 3.14159 * self._radius ** 2
@readonly
def circumference(self): return 2 * 3.14159 * self._radius
```
## 🧪 Test Etme
```bash
# Test suite'i çalıştır
python main.py
# Beklenen çıktı:
# ✅ Tüm read-only testleri geçti
# ✅ Multiple instance desteği çalışıyor
# ✅ Exception handling doğru
```
## 📊 Performans
```python
import timeit
# py-readonlyx (@readonly)
def test_readonly():
return user.readonly_prop
# Manuel property
def test_manual():
return user.manual_prop
# Her ikisi de ~aynı performans (native property hızı)
```
## 🤝 Katkıda Bulunma
1. Fork edin
2. Feature branch oluşturun (`git checkout -b feature/amazing-feature`)
3. Commit edin (`git commit -m 'Add amazing feature'`)
4. Push edin (`git push origin feature/amazing-feature`)
5. Pull Request açın
## 📄 Lisans
Apache 2.0 License - Detaylar için [LICENSE](LICENSE) dosyasına bakın.
## 🏷️ Versiyon Geçmişi
- **v1.0.0** - İlk kararlı sürüm
- `@readonly` decorator
- `ReadOnlyError` exception
- Tam test coverage
---
<div align="center">
**⭐ Beğendiyseniz yıldız vermeyi unutmayın!**</br>
**Created by ❤️ [firatmio](https://github.com/firatmio)**
</div>
Raw data
{
"_id": null,
"home_page": "https://github.com/firatmio/py-readonlyx",
"name": "py-readonlyx",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "readonly, property, decorator, immutable, python",
"author": "firatmio",
"author_email": "firatmio <firattunaarslan@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/ea/ba/8eff5bc4d46c0df11450593cdf940a8c4d1d9fee805fcb57b8515de3c154/py_readonlyx-1.6.0.tar.gz",
"platform": null,
"description": "<div align=\"center\">\r\n\r\n# \ud83d\ude80 py-readonlyx\r\n\r\n**Lightweight Python Read-Only Property Decorator**\r\n\r\n*Periyodik g\u00f6revlerinizi kolayca y\u00f6netin - S\u0131f\u0131r ba\u011f\u0131ml\u0131l\u0131k, maksimum performans*\r\n\r\n\r\n\r\n\r\n\r\n\r\n[](https://github.com/yourusername/py-readonlyx)\r\n[](https://github.com/yourusername/py-readonlyx)\r\n[](https://github.com/yourusername/py-readonlyx)\r\n\r\n</div>\r\n\r\n---\r\n\r\n## \ud83d\udcd6 Genel Bak\u0131\u015f\r\n\r\n**py-readonlyx**, Python s\u0131n\u0131flar\u0131nda read-only (salt okunur) property'ler olu\u015fturmak i\u00e7in tasarlanm\u0131\u015f minimal ve y\u00fcksek performansl\u0131 bir decorator k\u00fct\u00fcphanesidir. Sadece **tek bir decorator** ile property'lerinizi de\u011fi\u015ftirilemez hale getirebilirsiniz.\r\n\r\n## \ud83c\udfaf Neden py-readonlyx?\r\n\r\n### \ud83c\udd9a Di\u011fer \u00c7\u00f6z\u00fcmlerle Kar\u015f\u0131la\u015ft\u0131rma\r\n\r\n| \u00d6zellik | py-readonlyx | Manuel Property | dataclasses.frozen | attrs.frozen |\r\n|---------|--------------|-----------------|-------------------|--------------|\r\n| **Basitlik** | \u2705 Tek decorator | \u274c \u00c7ok kod | \u26a0\ufe0f S\u0131n\u0131f seviyesi | \u26a0\ufe0f Ba\u011f\u0131ml\u0131l\u0131k |\r\n| **Performans** | \u2705 Y\u00fcksek | \u2705 Y\u00fcksek | \u26a0\ufe0f Orta | \u26a0\ufe0f Orta |\r\n| **Ba\u011f\u0131ml\u0131l\u0131k** | \u2705 S\u0131f\u0131r | \u2705 S\u0131f\u0131r | \u2705 Stdlib | \u274c D\u0131\u015f paket |\r\n| **Se\u00e7ici Control** | \u2705 Property bazl\u0131 | \u2705 Property bazl\u0131 | \u274c T\u00fcm s\u0131n\u0131f | \u274c T\u00fcm s\u0131n\u0131f |\r\n| **Mutable Fields** | \u2705 Destekler | \u2705 Destekler | \u274c Desteklemez | \u274c Desteklemez |\r\n\r\n### \ud83d\udca1 Neden Bu K\u00fct\u00fcphaneyi Se\u00e7melisiniz?\r\n\r\n- **\ud83c\udfc3\u200d\u2642\ufe0f S\u0131f\u0131r \u00d6\u011frenme E\u011frisi**: Sadece `@readonly` ekleyin, haz\u0131r!\r\n- **\u26a1 Y\u00fcksek Performans**: Native Python property'lerinin performans\u0131\r\n- **\ud83e\udeb6 S\u0131f\u0131r Ba\u011f\u0131ml\u0131l\u0131k**: Harici paket gerektirmez\r\n- **\ud83c\udf9b\ufe0f Gran\u00fcler Kontrol**: Sadece istedi\u011finiz property'leri readonly yap\u0131n\r\n- **\ud83d\udd04 Karma Kullan\u0131m**: Ayn\u0131 s\u0131n\u0131fta readonly ve normal property'ler\r\n- **\ud83e\uddf5 Thread-Safe**: \u00c7oklu thread ortamlar\u0131nda g\u00fcvenli\r\n- **\ud83d\udce6 Minimal Footprint**: Toplam ~50 sat\u0131r kod\r\n\r\n## \ud83d\ude80 H\u0131zl\u0131 Ba\u015flang\u0131\u00e7\r\n\r\n### Kurulum\r\n\r\n```bash\r\n# Bu projeyi klonlay\u0131n\r\ngit clone https://github.com/yourusername/py-readonlyx.git\r\ncd py-readonlyx\r\n\r\n# Python path'inize ekleyin veya do\u011frudan import edin\r\n```\r\n\r\n### Temel Kullan\u0131m\r\n\r\n```python\r\nfrom py_readonlyx import readonly, ReadOnlyError\r\n\r\nclass User:\r\n def __init__(self, name=\"F\u0131rat\", age=25):\r\n self._name = name\r\n self._age = age\r\n self._status = \"active\" # Bu de\u011fi\u015ftirilebilir\r\n\r\n @readonly\r\n def name(self):\r\n \"\"\"Kullan\u0131c\u0131 ad\u0131 - salt okunur\"\"\"\r\n return self._name\r\n\r\n @readonly \r\n def age(self):\r\n \"\"\"Kullan\u0131c\u0131 ya\u015f\u0131 - salt okunur\"\"\"\r\n return self._age\r\n\r\n # Normal property - de\u011fi\u015ftirilebilir\r\n @property\r\n def status(self):\r\n return self._status\r\n \r\n @status.setter\r\n def status(self, value):\r\n self._status = value\r\n\r\n# Kullan\u0131m\r\nuser = User(\"Ahmet\", 30)\r\n\r\n# \u2705 Okuma i\u015flemleri\r\nprint(user.name) # \"Ahmet\"\r\nprint(user.age) # 30\r\n\r\n# \u2705 Normal property de\u011fi\u015fikli\u011fi \r\nuser.status = \"inactive\" # \u00c7al\u0131\u015f\u0131r\r\n\r\n# \u274c Read-only property de\u011fi\u015fikli\u011fi\r\nuser.name = \"Mehmet\" # ReadOnlyError\r\nuser.age = 35 # ReadOnlyError\r\ndel user.name # ReadOnlyError\r\n```\r\n\r\n## \ud83d\udee0\ufe0f Geli\u015fmi\u015f Kullan\u0131m\r\n\r\n### API Referans\u0131\r\n\r\n#### `@readonly` Decorator\r\n\r\nProperty'yi salt okunur hale getirir.\r\n\r\n```python\r\n@readonly\r\ndef property_name(self):\r\n return self._value\r\n```\r\n\r\n#### `ReadOnlyError` Exception\r\n\r\nRead-only property'ye yazma/silme giri\u015fiminde f\u0131rlat\u0131l\u0131r.\r\n\r\n```python\r\ntry:\r\n user.readonly_prop = \"new_value\"\r\nexcept ReadOnlyError as e:\r\n print(f\"Hata: {e}\")\r\n # \"Cannot set read-only property 'readonly_prop'\"\r\n```\r\n\r\n### Kullan\u0131m Senaryolar\u0131\r\n\r\n#### 1. Immutable Model Classes\r\n```python\r\nclass Point:\r\n def __init__(self, x, y):\r\n self._x, self._y = x, y\r\n \r\n @readonly\r\n def x(self): return self._x\r\n \r\n @readonly \r\n def y(self): return self._y\r\n```\r\n\r\n#### 2. Configuration Objects\r\n```python\r\nclass Config:\r\n def __init__(self, api_key, database_url):\r\n self._api_key = api_key\r\n self._database_url = database_url\r\n \r\n @readonly\r\n def api_key(self): return self._api_key\r\n \r\n @readonly\r\n def database_url(self): return self._database_url\r\n```\r\n\r\n#### 3. Computed Properties\r\n```python\r\nclass Circle:\r\n def __init__(self, radius):\r\n self._radius = radius\r\n \r\n @property\r\n def radius(self): return self._radius\r\n \r\n @radius.setter \r\n def radius(self, value): self._radius = value\r\n \r\n @readonly\r\n def area(self): return 3.14159 * self._radius ** 2\r\n \r\n @readonly\r\n def circumference(self): return 2 * 3.14159 * self._radius\r\n```\r\n\r\n## \ud83e\uddea Test Etme\r\n\r\n```bash\r\n# Test suite'i \u00e7al\u0131\u015ft\u0131r\r\npython main.py\r\n\r\n# Beklenen \u00e7\u0131kt\u0131:\r\n# \u2705 T\u00fcm read-only testleri ge\u00e7ti\r\n# \u2705 Multiple instance deste\u011fi \u00e7al\u0131\u015f\u0131yor \r\n# \u2705 Exception handling do\u011fru\r\n```\r\n\r\n## \ud83d\udcca Performans\r\n\r\n```python\r\nimport timeit\r\n\r\n# py-readonlyx (@readonly)\r\ndef test_readonly():\r\n return user.readonly_prop\r\n\r\n# Manuel property\r\ndef test_manual():\r\n return user.manual_prop\r\n\r\n# Her ikisi de ~ayn\u0131 performans (native property h\u0131z\u0131)\r\n```\r\n\r\n## \ud83e\udd1d Katk\u0131da Bulunma\r\n\r\n1. Fork edin\r\n2. Feature branch olu\u015fturun (`git checkout -b feature/amazing-feature`)\r\n3. Commit edin (`git commit -m 'Add amazing feature'`)\r\n4. Push edin (`git push origin feature/amazing-feature`)\r\n5. Pull Request a\u00e7\u0131n\r\n\r\n## \ud83d\udcc4 Lisans\r\n\r\nApache 2.0 License - Detaylar i\u00e7in [LICENSE](LICENSE) dosyas\u0131na bak\u0131n.\r\n\r\n## \ud83c\udff7\ufe0f Versiyon Ge\u00e7mi\u015fi\r\n\r\n- **v1.0.0** - \u0130lk kararl\u0131 s\u00fcr\u00fcm\r\n - `@readonly` decorator\r\n - `ReadOnlyError` exception\r\n - Tam test coverage\r\n\r\n---\r\n\r\n<div align=\"center\">\r\n\r\n**\u2b50 Be\u011fendiyseniz y\u0131ld\u0131z vermeyi unutmay\u0131n!**</br>\r\n**Created by \u2764\ufe0f [firatmio](https://github.com/firatmio)**\r\n\r\n</div>\r\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "Lightweight Python Read-Only Property Decorator",
"version": "1.6.0",
"project_urls": {
"Bug Tracker": "https://github.com/firatmio/py-readonlyx/issues",
"Documentation": "https://github.com/firatmio/py-readonlyx#readme",
"Homepage": "https://github.com/firatmio/py-readonlyx",
"Repository": "https://github.com/firatmio/py-readonlyx"
},
"split_keywords": [
"readonly",
" property",
" decorator",
" immutable",
" python"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "7d385f8362bc2b5e8b5b88c3f2ad599f5156a475f88b5e89c9f3f4fab5bba015",
"md5": "ee9453dd5295c6aa2ab8df48fb06ffdc",
"sha256": "cc39a9d04d79837313d7064490a6087a02f330f185a1d596d7bce23534527e21"
},
"downloads": -1,
"filename": "py_readonlyx-1.6.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "ee9453dd5295c6aa2ab8df48fb06ffdc",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 8819,
"upload_time": "2025-08-01T11:33:07",
"upload_time_iso_8601": "2025-08-01T11:33:07.683268Z",
"url": "https://files.pythonhosted.org/packages/7d/38/5f8362bc2b5e8b5b88c3f2ad599f5156a475f88b5e89c9f3f4fab5bba015/py_readonlyx-1.6.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "eaba8eff5bc4d46c0df11450593cdf940a8c4d1d9fee805fcb57b8515de3c154",
"md5": "b346b4ad48261c5382b59f5299bbf79f",
"sha256": "c0f551f344d69742896df786585983d22180d2e09b598caf244a032e4acf934a"
},
"downloads": -1,
"filename": "py_readonlyx-1.6.0.tar.gz",
"has_sig": false,
"md5_digest": "b346b4ad48261c5382b59f5299bbf79f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 9265,
"upload_time": "2025-08-01T11:33:08",
"upload_time_iso_8601": "2025-08-01T11:33:08.906692Z",
"url": "https://files.pythonhosted.org/packages/ea/ba/8eff5bc4d46c0df11450593cdf940a8c4d1d9fee805fcb57b8515de3c154/py_readonlyx-1.6.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-01 11:33:08",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "firatmio",
"github_project": "py-readonlyx",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "py-readonlyx"
}