You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/classes.md
+47-2Lines changed: 47 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,15 @@
2
2
3
3
Pyccel strives to provide robust support for object-oriented programming concepts commonly used by developers. In Pyccel, classes are a fundamental building block for creating structured and reusable code. This documentation outlines key features and considerations when working with classes in Pyccel.
4
4
5
+
## Contents
6
+
7
+
1.[Constructor Method](#constructor-method)
8
+
2.[Destructor Method](#destructor-method)
9
+
3.[Class Methods](#class-methods)
10
+
4.[Class Properties](#class-properties)
11
+
5.[Magic Methods](#magic-methods)
12
+
6.[Limitations](#limitations)
13
+
5
14
## Constructor Method
6
15
7
16
- The Constructor Method, `__init__`, is used to initialise the object's attributes.
@@ -188,7 +197,7 @@ MyClass Object created!
188
197
==158858== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
189
198
```
190
199
191
-
## Class properties
200
+
## Class Properties
192
201
193
202
Pyccel now supports class properties (to retrieve a constant value only).
194
203
@@ -415,6 +424,42 @@ int main()
415
424
call obj % free()
416
425
```
417
426
427
+
## Magic Methods
428
+
429
+
Pyccel supports a subset of magic methods that are listed here:
430
+
431
+
- `__add__`
432
+
- `__sub__`
433
+
- `__mul__`
434
+
- `__truediv__`
435
+
- `__pow__`
436
+
- `__lshift__`
437
+
- `__rshift__`
438
+
- `__and__`
439
+
- `__or__`
440
+
- `__iadd__`
441
+
- `__isub__`
442
+
- `__imul__`
443
+
- `__itruediv__`
444
+
- `__ipow__`
445
+
- `__ilshift__`
446
+
- `__irshift__`
447
+
- `__iand__`
448
+
- `__ior__`
449
+
450
+
Additionally the following methods are supported in the translation but are lacking the wrapper support that would allow them to be called from Python code:
451
+
452
+
- `__radd__`
453
+
- `__rsub__`
454
+
- `__rmul__`
455
+
- `__rtruediv__`
456
+
- `__rpow__`
457
+
- `__rlshift__`
458
+
- `__rrshift__`
459
+
- `__rand__`
460
+
- `__ror__`
461
+
- `__contains__`
462
+
418
463
## Limitations
419
464
420
-
It's important to note that Pyccel does not support class inheritance, magic methods or static class variables. For our first implementation, the focus of Pyccel is primarily on core class functionality and memory management.
465
+
It's important to note that Pyccel does not support class inheritance, or static class variables. For our first implementation, the focus of Pyccel is primarily on core class functionality and memory management.
0 commit comments