PEP: xxx
Title: A method for exposing a length hint
Version:
class HelloWorld { | |
public static void main(String args[]) { | |
System.out.println("Hello World") | |
} | |
} |
class HelloWorld { | |
public static void main(String args[]) { | |
System.out.println("Hello World") | |
} | |
} |
class HelloWorld { | |
public static void main(String args[]) { | |
System.out.println("Hello World") | |
} | |
} |
[This is a follow up on the work I did last semester. Some of the descriptive text is the same.]
PyPy is an implementation of Python, written in (a restricted subset of) Python, featuring an advanced tracing just-in-time compiler. It is currently the fastest implementation of Python available.
So it turns out, what we do now is really silly. We just iterate over every
ConstPtr()
(these are GC pointer boxes within the JIT's optimizers that
refer to concrete pointers) and run the GC until the object is non-movable.
This isn't particularly bad with our current default GC, because it has two
generations so a single collection promotes all the ConstPtrs
to
non-movable (and in practice they were very likely non-movable before we even
try to force it). The more intelligent approach would be to have each piece of
Paul McMillan (Django security guru and all-around smart guy) and I just spent quite a while discussing this issue, here's what we came up with:
First, this is an issue which, if at all possible should be solved at the language level. This is because it's often hard to tell where data comes from a user, and where it's safe.
We're also in agreement that this should be solved at the language level, and shouldn't be configurable. It will be far to easy to deploy in an enviroment that's insecure if you get it wrong.
import traceback | |
class WebApp(object): | |
def __init__(self, obj): | |
self.obj = obj | |
def __call__(self, environ, start_response): | |
try: | |
path = filter(bool, environ["PATH_INFO"].split("/")) |
from django.shortcuts import get_object_or_404, render_to_response | |
from django.template import RequestContext | |
from myapp.models import Note | |
def note_detail(request, slug): | |
note = get_object_or_404(Note, slug=slug) | |
editable = request.user.is_authenticated and request.user.id == note.author.id | |
return render_to_response('myapp/note_detail.html', { |
import operator | |
from django.db.models import Q | |
from django.shortcuts import _get_queryset | |
def search(klass, search_fields, search_string): | |
""" | |
Perform a quick and dirty model "search", similar to how the admin's | |
`search_fields` works (see http://tinyurl.com/66xz2n):: |