This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2016年03月11日 17:18 by Devyn Johnson, last changed 2022年04月11日 14:58 by admin. This issue is now closed.
| Messages (4) | |||
|---|---|---|---|
| msg261582 - (view) | Author: Devyn Johnson (Devyn Johnson) | Date: 2016年03月11日 17:18 | |
Would it be a good idea to add macros to Python? This would allow developers to test a condition (such as, "is this code running on Linux?" or "is this Python version 3.6?"). Then, the compiled bytecode will already contain the needed code, as opposed to testing the conditions during each execution. |
|||
| msg261583 - (view) | Author: Ethan Furman (ethan.furman) * (Python committer) | Date: 2016年03月11日 17:25 | |
That particular use-case is easily handled by simply creating the correct function/method based on the criterion: if py_ver < 3.6: def fribbletz(): # do something in a 3.0-3.5 compatible way else: def fribbletz(): # otherwise use 3.6 methods One possible up-side would by if macros were able to allow not erroring out when new syntax was used in the False branch; but really, we add new syntax so rarely even that is probably not worth it. |
|||
| msg261594 - (view) | Author: Mark Dickinson (mark.dickinson) * (Python committer) | Date: 2016年03月11日 19:33 | |
This is really python-ideas material: you'd need to give a *lot* more details about exactly what you mean by "macros". |
|||
| msg261596 - (view) | Author: Ezio Melotti (ezio.melotti) * (Python committer) | Date: 2016年03月11日 19:40 | |
Agreed, this is python-ideas material. The topic also came up in the past, and there are already threads where this has been discussed and even existing projects that implements macros. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:58:28 | admin | set | github: 70727 |
| 2016年03月11日 19:40:30 | ezio.melotti | set | status: open -> closed nosy: + ezio.melotti messages: + msg261596 resolution: not a bug stage: resolved |
| 2016年03月11日 19:33:29 | mark.dickinson | set | nosy:
+ mark.dickinson messages: + msg261594 |
| 2016年03月11日 17:25:54 | ethan.furman | set | nosy:
+ ethan.furman messages: + msg261583 |
| 2016年03月11日 17:18:22 | Devyn Johnson | create | |