Notice: While JavaScript is not essential for this website, your interaction with the content will be limited. Please turn JavaScript on for the full experience.
...functions written in Python in your inner loop. This includes lambdas. In-lining the inner loop can save a lot of time. Local variables are faster than globals; if you use a global constant in a loop, copy it to a local variable before the loop. And in Python, function names (global or built-in) are also global constants! Try to use map(), filter() or reduce() to replace an explicit for loop, but only if you can use a built-in function: map with a built-in function beats for loop,...
...built-ins built-in sets - the sets module, introduced in 2.3, has now been implemented in C, and the set and frozenset types are available as built-in types (PEP 218) unification of integers and long integers - an operation that would return a number too big for an integer will automatically return a long integer. (PEP 237) generator expressions - generator expressions are similar to a list comprehension, but instead of creating the entire list of results they create a generator that returns t...
...built-in, naming the featureless base type of all built-in types under the new system. When using multiple inheritance, you can mix classic classes and built-in types (or types derived from built-in types) in the list of base classes. (This is new in Python 2.2b2; in earlier versions you couldn't.) See also the general bugs in 2.2 list. Built-in types as factory functions The previous section showed that an instance of the built-in subtype defaultdict can be created by ca...
...built-in HTTP server with an underlying spider to collect web documents, and a query engine to serve search results back to the user. The interface, including the administrative console, is served over the built-in HTTP server using Python-scripted HTML. Some of the modules, such as the search spider, GUI, and HTTP server, were written in Python. For performance reasons, others, such as the query engine, indexer, and HTML parser, use the Python/C API to incorporate functionality written in C. Th...
...functions which return pointers or non-const references, in order to prevent dangling pointers and references from causing crashes on the Python side. This limits the library's ability to export arbitrary C++ functions. Goal: Implementation of a mechanism by which references and pointers to internal elements of function and method arguments can be returned safely. This will include a mechanism by which any argument object can be kept alive during the lifetime of any...
...functions are now different more often. For long integers, str() no longer appends a 'L'. Thus, str(1L) == '1', which used to be '1L'; repr(1L) is unchanged and still returns '1L'. For floats, repr() now gives 17 digits of precision, to ensure no precision is lost (on all current hardware). The -X option is gone. Built-in exceptions are now always classes. Many more library modules also have been converted to class-based exceptions. Binary Incompatibilities T...
...functions are now different more often. For long integers, str() no longer appends a 'L'. Thus, str(1L) == '1', which used to be '1L'; repr(1L) is unchanged and still returns '1L'. For floats, repr() now gives 17 digits of precision, to ensure no precision is lost (on all current hardware). The -X option is gone. Built-in exceptions are now always classes. Many more library modules also have been converted to class-based exceptions. Binary Incompatibilities Third party extensions built fo...
Summary of "Extension Building" Session "Extension Building Considered Painful": Session Summary by Greg Ward The "Extension Building Considered Painful" session at IPC7 was very productive, and there was a good consensus in the room as to what's needed, what will work for various classes of users, and what ideas to steal from other related systems (the closest being Red Hat's RPM and Perl's MakeMaker). Decisions made Everyone seemed to agree with my p...
Built-in Package Support in Python 1.5 Built-in Package Support in Python 1.5 Starting with Python version 1.5a4, package support is built into the Python interpreter. This implements a slightly simplified and modified version of the package import semantics pioneered by the "ni" module. "Package import" is a method to structure Python's module namespace by using "dotted module names". For example, the module name A.B designates a submodule named B in a package named A. Just like...
Python Success Stories Introduction LoveIntros is an online singles community for people living in the Northwest United States. The LoveIntros Web application allows members to create personal profiles, send and receive anonymous e-mails, create private Web journals, perform advanced profile searches, and execute many other functions. By providing a safe and effective way for individuals to find each other, LoveIntros makes it easier to meet new people who have similar interests and values an...
...built-in object types from user-defined classes, and currently doesn't allow inheritance from built-in types. Smalltalk's standard library of collection data types is more refined, while Python's library has more facilities for dealing with Internet and WWW realities such as email, HTML and FTP. Python has a different philosophy regarding the development environment and distribution of code. Where Smalltalk traditionally has a monolithic "system image" which comprises both the environme...
...functions are by name, not by value -- two mutually recursive functions can still both have a reference count of one, since they do a name lookup for each other. C1 is an attempt to provide a way for a module to define globals that are deleted before anything else in the module. Since imported module or function names generally don't begin with an underscore, this means that such objects can be guaranteed that any imported modules or functions still exist when they are deleted -- pro...
...built-in support for importing hierarchical module names (e.g. "import spam.ham.eggs"); ni is declared obsolete. Note that the built-in package support is somewhat simpler (no __ and __domain__) and differs in one crucial aspect: __init__.py is required, and loaded in the package's namespace instead of as a submodule. For more information, see Built-in Package Support. The new "re" module (Perl style regular expressions) is here. It is based on Philip Hazel's pcre code; th...
...functions themselves are given a reference to the Properties manager so they can recursively request any additionally needed dependencies. To add a new prediction we register the new function in the function table -- and let the functions themselves handle the dependencies. The cache is needed because some properties are expensive to compute or are needed by many other properties. Architecture of the Property Manager Zoom in The resulting new architecture made a simple but profound difference...
...Functions and methods now support getting and setting arbitrarily named attributes (PEP 232). Functions have a new __dict__ (a.k.a. func_dict) which hold the function attributes. Methods get and set attributes on their underlying im_func. It is a TypeError to set an attribute on a bound method. The xrange() object implementation has been improved so that xrange(sys.maxint) can be used on 64-bit platforms. There's still a limitation that in this case len(xrange(sys.maxint)) can't be calculat...
...built-in types). Use the new and improved dir() function instead. <p><li>type("").__name__ == "str" # was "string" <p><li>type(0L).__name__ == "long" # was "long int" <p><li>Overflowing int operations return the corresponding long value rather than raising the OverflowError exception. <p><li>Conversion of long to float now raises OverflowError if the long is too big to represent as a C double. Thi...
If you didn't find what you need, try your search in the Python language documentation.