Frankie Ribery
Frankie Ribery

Reputation: 12153

Differences between compiler and ast module in python

The compiler module has been deprecated in python 2.6. Does anybody know what is the reason behind the deprecation ? Is the ast module a direct replacement ? Will the ast module be supported in python 3k ?

Upvotes: 3

Views: 602

Answers (2)

ncoghlan
ncoghlan

Reputation: 41496

The compiler module was a Python compiler written in Python. It was horribly slow and a pain to maintain.

The ast module is a smarter solution to the same problem: it provides Python level access to the actual compiler used when importing modules. Since it is just a visible API for the builtin compiler, it isn't going anywhere.

ast isn't a drop-in replacement for compiler (i.e. the APIs are different), but it certainly covers many of the same use cases.

Upvotes: 6

Tim Pietzcker
Tim Pietzcker

Reputation: 336148

Yes, the ast module replaces the compiler module. And what do you mean by "will be supported"? Python 3 has been out for years, and of course ast is part of its standard library.

Reasons for the removal can be found here.

Upvotes: 4

Related Questions