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.

classification
Title: Python Macros
Type: enhancement Stage: resolved
Components: Interpreter Core Versions: Python 3.6
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Devyn Johnson, ethan.furman, ezio.melotti, mark.dickinson
Priority: normal Keywords:

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:28adminsetgithub: 70727
2016-03-11 19:40:30ezio.melottisetstatus: open -> closed

nosy: + ezio.melotti
messages: + msg261596

resolution: not a bug
stage: resolved
2016-03-11 19:33:29mark.dickinsonsetnosy: + mark.dickinson
messages: + msg261594
2016-03-11 17:25:54ethan.furmansetnosy: + ethan.furman
messages: + msg261583
2016-03-11 17:18:22Devyn Johnsoncreate